IOS开发 一级页面右滑返回 页面卡顿处理
问题 : 最近在在app一级页面进行系统左侧右滑返回的时候,经常出现界面卡死,只能回到手机首页,再进入app才能继续操作app。
解决方法: app一级页面,大家都知道再返回是没有任何相关的页面,由于这个原因造成页面卡死,所以现在在一级页面分别添加禁用和开启右滑返回手势。
@property(nonatomic, assign)BOOL isCanUseSideBack;// 手势是否启动
-(void)viewDidAppear:(BOOL)animated{
[superview DidAppear:animated];
[self cancelSideBack];
}
- (void)viewDidDisappear:(BOOL)animated {
[superview DidDisappear:animated];
[self startSideBack];
}
/**
* 关闭ios右滑返回
*/
-(void)cancelSideBack{
self.isCanUseSideBack=NO;
if([self.navigationControllerrespondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate=self;
}
}
/*
开启ios右滑返回
*/
- (void)startSideBack {
self.isCanUseSideBack=YES;
if([self.navigationControllerrespondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate=nil;
}
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {
return self.isCanSideBack;
}