Reputation: 2564
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?
Upvotes: 8
Views: 4543
Reputation:
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
Upvotes: 4