Re-enable iOS7 swipe-to-back while custom back button is set.
-
With setting custom back button via
leftBarButtonItem, default swipe-to-back gesture is disabled. -
Assigning
interactivePopGestureRecognizerasUINavigationController(a common solution) can cause unexpected errors:- nested pop animation can result in corrupted navigation bar
- Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
-
Put custom code everywhere around
UINavigationControlleris too annoying.
-
Not annoying
You don't need to code. -
iOS7 native behavior
Not a foolishly-customized gesture recognizer. -
Safe
No error anymore.
Just add a line below into your Podfile. You don't need to write any code. CocoaPods automatically import SwipeBack globally.
pod 'SwipeBack'
Import SwipeBack at your .pch file.
#import "SwipeBack.h"
It's done.
See UINavigationController+SwipeBack.m and UIViewController+SwipeBack.m. Want to know more about method swizzling, visit here.