1. 创建类 继承 UINavigationController
2.- (void)viewDidLoad {
[super viewDidLoad];
// 获取系统自带滑动手势的target对象
id target = self.interactivePopGestureRecognizer.delegate;
// 创建全屏滑动手势, 调用系统自带滑动手势target的action方法
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:NSSelectorFromString(@"handleNavigationTransition:")];
// 设置手势代理, 拦截手势触发
pan.delegate=self;
// 给导航控制器的View添加全屏滑动手势
[self.view addGestureRecognizer:pan];
//禁止使用系统自带的滑动手势
self.interactivePopGestureRecognizer.enabled = NO;
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer
{
//如过是根视图 , 返回NO
if (self.childViewControllers.count == 1) {
returnNO;
}
return YES;
}
3.不要忘记签协议<UIGestureRecognizerDelegate> ,然后成功了, 然后快乐就行了