navigationcontroller的返回按钮如果用的是系统按钮
self.navigationController.interactivePopGestureRecognizer.enabled = YES
写入上述代码就可以了
如果隐藏了导航条,自定义了样式
self.navigationController.interactivePopGestureRecognizer.delegate = self;
填写上述代码就可以,不过只能从左边缘滑动返回
如果想要全屏滑动或者自定义范围
id target = self.navigationController.interactivePopGestureRecognizer.delegate;
UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:target action:@selector(handleNavigationTransition:)];
pan.delegate = self;
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
[self.view addGestureRecognizer:pan];