UINavigationController: Clean interactive transition to view controller without navigation bar?
UINavigationController: Clean interactive transition to view controller without navigation bar?
- Subject: UINavigationController: Clean interactive transition to view controller without navigation bar?
- From: Daniel Stenmark <email@hidden>
- Date: Sun, 21 Feb 2016 01:04:01 +0000
- Thread-topic: UINavigationController: Clean interactive transition to view controller without navigation bar?
(Already asked on StackOverflow, but might as well cover my bases here as well.)
I have a view controller navigation hierarchy where only the top view controller has its navigation bar hidden. Normal pushing/popping is fine and works as expected. However, when the pop is interactive (drag-to-pop), the top opaque bar doesn't disappear until the transition is finished. I've implemented the logic in the following delegate call:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if( [viewController isKindOfClass:[MyTopViewController class]] == YES ) {
id<UIViewControllerTransitionCoordinator> transitionCoordinator = viewController.transitionCoordinator;
if( transitionCoordinator != nil && transitionCoordinator.initiallyInteractive == YES ) {
[transitionCoordinator notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
if( context.isCancelled == YES ) {
return;
}
[navigationController setNavigationBarHidden:YES animated:animated];
}];
} else {
[navigationController setNavigationBarHidden:YES animated:animated];
}
} else {
[navigationController setNavigationBarHidden:NO animated:animated];
}
}
I've already attempted numerous variations of this, but each one has had various issues with interactive transitions, especially if the transition is canceled mid-way. What's the best way to approach this?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden