我们在做项目或者自定义导航控制器的返回视图的时候,可能会破坏系统的右滑返回上一级菜单的手势事件;有时可能隐藏了导航栏也会产生这种情况;
解决方案如下,再将控制器push的代码之后 或者在prepareForSegue 方法里面加上这行代码
- (void)viewDidLoad {
[super viewDidLoad];
//重点
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
self.view.backgroundColor = [UIColor purpleColor];
#pragma mark--button create
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(100, 100, 100, 50);
btn.backgroundColor = [UIColor orangeColor];
[btn addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
}
- (void)clicked:(UIButton *)senf {
[self.navigationController popViewControllerAnimated:YES];
}
这是因为覆盖了系统的返回按钮事件,系统将会通过代理禁用这个滑动返回功能,提前取消系统的delegate,这样滑动返回功能就OK了。