我有一个视图控制器导航层次结构,其中只有顶视图控制器隐藏其隐藏的导航栏。正常的推/弹是很好的,并按预期工作。但是,当弹出交互式(拖放)时,顶部不透明栏在转换完成之前不会消失。我在以下委托调用中实现了逻辑:
- (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];
}
}
我已经尝试了很多这方面的变化,但每个都有交互式过渡的各种问题,特别是如果过渡在中途被取消。什么是解决这个问题的最佳方法?