在RootViewController右划返回手势也可以响应,因为没有上一级页面,导致整个程序页面不响应,当页面从A跳转到B页面时,偶尔会卡死。我以为是b页面的viewdidload做的事情太多了,也做了简化,包括加上线程处理。
后来发现,压根不是这回事,即使跳到超级简单的页面也会卡。当按下home键,再次点开app时,又能跳到b页面了。
APP做出如下修改
在一级页面进入和离开时 分别添加禁用和开启右滑返回手势
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self forbiddenSideBack];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[self resetSideBack];
}
禁用手势
/**
* 禁用边缘返回
*/
-(void)forbiddenSideBack{
self.isCanSideBack = NO;
//关闭ios右滑返回
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate=self;
}
}
/*
恢复边缘返回
*/
- (void)resetSideBack {
self.isCanSideBack=YES;
//开启ios右滑返回
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {
return self.isCanSideBack;
}