如果没记错,从iOS7开始加入了屏幕边缘返回手势(无需设置),但是如果自定义返回按钮的话则失效,这时候就需要下面的方法:
因为我是系统分级的项目,所以就直接写在了UITabBarController中:
即
AppDelegate中:
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
TCTabBarController *tabbarVc = [[TCTabBarController alloc]init];
self.window.rootViewController = tabbarVc;
TCTabBarController中:
TCNavigationController *nav = [[TCNavigationController alloc]initWithRootViewController:childVc];
**在这里加上下面两句**
childVc.navigationController.interactivePopGestureRecognizer.enabled = YES;
childVc.navigationController.interactivePopGestureRecognizer.delegate = self;//遵守UIGestureRecognizerDelegate
[self addChildViewController:nav];
实现代理方法
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
return YES;
}
搞定!