So I have a navigation controller in my built for iOS 7 app. The titleView is visible, as well as the back button and navigation bar its self. For some reason, the interactive pop gesture (swipe from the left edge) isn't working. Nothing happens. When I log the gesture, it is not nil. Is there anything special I have to do to enable this functionality? What could cause it not to work?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
You can put this line in the viewDidLoad method.
Look at this response and comments. All you have to do is set your navigation controller's interactive pop gesture recognizer's delegate to
nil
:Setting it to a casted self to
id<UIGestureRecognizerDelegate>
also works because all methods in the protocol are optional, but I think setting the delegate tonil
is more appropriate in this case.In Swift 4, I have a UITableView inside my view controller, I solved this issue with:
The more worked out answer was both Aaron and lojals
First Customise the Navigation controller and then put this code in the class
In ViewDidload put this line:
And in class write this function
Eh, looks like I just had to set the gesture delegate and implement the following:
I have found that when using custom back buttons, the interactive pop gesture stops working (my take is that Apple cannot foresee how your custom back button will behave, so they disable the gesture).
To fix this, as other mentioned before, you can set the
interactivePopGestureRecognizer.delegate
property tonil
.In Swift,
this can easily be done across your entire application by adding an extension for:UINavigationController
like thisUpdated answer
Seems like setting the delegate to
nil
causes the app UI to freeze in some scenarios (eg. when the user swipes left or right on the top view controller of the navigation stack).Because
gestureRecognizerShouldBegin
delegate method cannot be handled in an extension, subclassingUINavigationController
seems like the best solution: