I have a UINavigationController subclass, which manages a custom navigation bar. This navigation bar's look depends on the top view controller. I ask the top view controller about the type of the bar to be displayed when -pushViewController:animated:
or -popViewControllerAnimated:
happens.
The problem is, that the navigation bar type change is played when the user starts swiping but I could not find any event which tells me that the swipe was successful or not, so if the user cancels the swipe, I stuck on the previous view controller with the desired navigation bar look of the one below it in the navigation stack.
I have tried UINavigationControllerDelegate
, but neither -navigationController:didShowViewController:animated:
nor -navigationController:didShowViewController:animated:
gets called. My second thought was to use interactiveGestureRecognizer
, but it seems it it ends successfully both on successful and cancelled back swipe, and the topViewController
is also still the same when the recognizer event is called.
I know, that the top view controller's -viewDidAppear
will be called again upon cancelled swipe, but I don't want my users to implement any logic in their controllers to support my navigation implementation.
Any ideas?
As a side note, to quickly return to default settings without using the ADB command, go to Settings –> System –> Gestures –> System navigation on your device. Tap the gear icon, then adjust the gesture sensitivity slider for the left edge to set things back to normal.
EDIT. If you want to manage swipe back feature for specific navigation controllers, consider using SwipeBack. With this, you can set navigationController. swipeBackEnabled = NO .
The gesture recognizer responsible for popping the top view controller off the navigation stack. iOS 7.0+ iPadOS 7.0+ Mac Catalyst 13.1+
Try using the UINavigationControllerDelegate, you can rely on its callbacks to know when a viewController is going to be displayed or not.
Getting interactivePopGestureRecognizer dismiss callback/event
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With