1.iOS7之后系统提供了侧滑手势(interactivePopGestureRecognizer),即从屏幕左侧边缘滑起会pop回导航控制器栈的上个viewController。
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
{
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
2.如果你自定义了UINavigationViewController或者自定义了返回按钮
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
{
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
3.我的app在使用系统提供的侧滑手势时,出现了页面假死现象,于是我就替换了系统自带的侧滑手势
id target = self.navigationController.interactivePopGestureRecognizer.delegate;
SEL handler = NSSelectorFromString(@"handleNavigationTransition:");
self.LeftScreenGes = [[UIScreenEdgePanGestureRecognizer alloc]initWithTarget:target action:handler];
self.LeftScreenGes.edges = UIRectEdgeLeft;
self.LeftScreenGes.delegate = self;
[self.view addGestureRecognizer:self.LeftScreenGes];
// 关闭边缘触发手势 防止和原有边缘手势冲突
[self.navigationController.interactivePopGestureRecognizer setEnabled:NO];
4.系统提供了侧滑手势,必须从屏幕边缘左侧滑起才会触发,替换成全屏触发
id target = self.navigationController.interactivePopGestureRecognizer.delegate;
SEL handler = NSSelectorFromString(@"handleNavigationTransition:");
// 创建pan手势 作用范围是全屏
self.fullScreenGes = [[UIPanGestureRecognizer alloc]initWithTarget:target action:handler];
self.fullScreenGes.delegate = self;
[self.view addGestureRecognizer:self.fullScreenGes];
// 关闭边缘触发手势 防止和原有边缘手势冲突
[self.navigationController.interactivePopGestureRecognizer setEnabled:NO];