系统侧滑必须从左侧屏幕边缘开始滑动,很不方便。所以使用手势替代系统侧滑。
遵循手势delegate
UIGestureRecognizerDelegate
// 禁用系统自带侧滑
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
// 获取系统自带滑动手势的target对象
id target = self.navigationController.interactivePopGestureRecognizer.delegate;
// 创建全屏滑动手势,调用系统自带滑动手势的target的action方法
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
// 设置手势代理,拦截手势触发
pan.delegate = self;
// 给导航控制器的view添加全屏滑动手势
[self.view addGestureRecognizer:pan];
- (void)handleNavigationTransition:(UIPanGestureRecognizer*)sender{
[self.navigationController popViewControllerAnimated:1];
}