Reputation: 1168
I have a viewcontroller with a custom navigation push transition using UINavigationControllerDelegate. Everything works perfectly when you start the animation, press the back button, etc.
However, if you push the viewcontroller onto the stack, background the app, return, then press back, the delegate method animationControllerForOperation is not called as it should be. during debugging, I have verified that self.navigationController.delegate is still properly set when we return app to foreground, but the delegate callback is never hit. Any ideas?
//presenting vc
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController*)fromVC
toViewController:(UIViewController*)toVC
{
if (operation == UINavigationControllerOperationPush) {
_animationObject = [LVDashboardExplainerAnimation new];
_animationObject.presenting = YES;
return _animationObject;
} else if (operation == UINavigationControllerOperationPop) {
_animationObject.presenting = NO;
return _animationObject;
}
return nil;
}
//other VC
- (void)headerTapped {
self.navigationController.delegate = _navigationDelegate; //correct object
[self.navigationController popViewControllerAnimated:YES];
}
Upvotes: 2
Views: 1882
Reputation: 1168
The problem stemmed from manually calling viewWillAppear:animated when the app returned from being backgrounded. By calling this, the navigation delegate would call willShowViewController:animated: but not navigationController:animationControllerForOperation: or didShowViewController:animated:
For some reason, forcefully calling viewWillAppear throws the whole thing off. Even if we accounted for this and set the navigation delegate to nil, then back the the correct object, the functionality would not work correctly. I'm guessing this is a bug in the SDK, but for now we removed the forced call to viewWillAppear.
Upvotes: 1