代码
- (void)viewDidLoad {
[super viewDidLoad];
//获取全屏滑动代理
id target = self.interactivePopGestureRecognizer.delegate;
//不提示警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
#pragma clang diagnostic pop
[self.view addGestureRecognizer:pan];
// 取消边缘滑动手势
self.interactivePopGestureRecognizer.enabled = NO;
pan.delegate = self;
}
pragma mark ---- <UIGestureRecognizerDelegate>
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
if ([[otherGestureRecognizer view] isKindOfClass:[UIScrollView class]]) {
UIScrollView *scrollView = (UIScrollView*)[otherGestureRecognizer view];
if (scrollView.contentOffset.x == 0) {
return YES;
}else{
return NO;
}
}
return YES;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
// 判断下当前是不是在根控制器
return self.childViewControllers.count > 1;
}
pragma mark ---- <非跟视图隐藏TarBar>
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
if (self.viewControllers.count > 0) {
viewController.hidesBottomBarWhenPushed = YES;
}
[super pushViewController:viewController animated:animated];
}
@end