app一级页面,再返回没有任何相关的页面,由于这个原因造成页面卡死,所以现在在一级页面分别添加禁用和开启右滑返回手势。
//在一级界面显示出来后取消右滑手势
- (void)viewDidAppear:(BOOL)animated {
[superviewDidAppear:animated];
[self cancelSideBack];
}
//在一级界面消失后开启右滑手势
- (void)viewDidDisappear:(BOOL)animated {
[superviewDidDisappear:animated];
[self startSideBack];
}
//关闭ios右滑返回
-(void)cancelSideBack {
self.isCanUseSideBack = NO;
if([self.navigationControllerrespondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate=(id)self;
}
}
//开启ios右滑返回
-(void)startSideBack {
self.isCanUseSideBack=YES;
if([self.navigationControllerrespondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}
//当在第一级界面右滑时会返回 YES,因为可能你已经push过了然后又pop回来,以至于右滑被关闭,所以需要设置为 YES
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {
return self.isCanUseSideBack;
}
网友评论