IOS開發(fā) 一級(jí)頁面右滑返回 頁面卡頓處理

問題 : 最近在在app一級(jí)頁面進(jìn)行系統(tǒng)左側(cè)右滑返回的時(shí)候,經(jīng)常出現(xiàn)界面卡死,只能回到手機(jī)首頁,再進(jìn)入app才能繼續(xù)操作app。

解決方法:?app一級(jí)頁面,大家都知道再返回是沒有任何相關(guān)的頁面,由于這個(gè)原因造成頁面卡死,所以現(xiàn)在在一級(jí)頁面分別添加禁用和開啟右滑返回手勢。

@property(nonatomic, assign)BOOL ?isCanUseSideBack;// 手勢是否啟動(dòng)

-(void)viewDidAppear:(BOOL)animated{

? ? ? ? ?[superview DidAppear:animated];

? ? ? ? [self cancelSideBack];

}

-?(void)viewDidDisappear:(BOOL)animated?{

? ? ? ? ? [superview DidDisappear:animated];

? ? ? ? ? ?[self startSideBack];

}

/**

*?關(guān)閉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;

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容