1、添加代理 UINavigationControllerDelegate
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setHidden:YES];
if ([[[UIDevice currentDevice] systemVersion] floatValue] > 7.0) {
self.navigationController.delegate = self;
}
}
- (void)viewWillDisappear:(BOOL)animated{
if ([[[UIDevice currentDevice] systemVersion] floatValue] > 7.0) {
self.navigationController.delegate = nil;
}
}
2、实现代理方法
//监听滑动手势
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
id <UIViewControllerTransitionCoordinator>tc = navigationController.topViewController.transitionCoordinator;
[tc notifyWhenInteractionChangesUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
[dataKit kit].reloadFlage = [context isCancelled];
}];
}
[context isCancelled] 是BOOL类型,未返回[context isCancelled]==YES,返回成功[context isCancelled]==NO。
点击按钮返回 或使用 [navigationController popviewcontorller] 不进入此回调。
网友评论