本文實(shí)例為大家分享了iOS禁用右滑返回的具體代碼,供大家參考,具體內(nèi)容如下
方式一:
前提:如果使用的自定義UINavigationController基類(lèi),請(qǐng)不要在此基類(lèi)里寫(xiě)相關(guān)的手勢(shì)操作方法。
代碼如下:
-(void)viewDidAppear:(BOOL)animated{ if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } } -(void)viewWillDisappear:(BOOL)animated{ self.navigationController.interactivePopGestureRecognizer.enabled = YES; }
方式二:
流程:先設(shè)置代理---->重寫(xiě)手勢(shì)操作方法
-(void)viewDidAppear:(BOOL)animated{ self.navigationController.interactivePopGestureRecognizer.delegate = self; } - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{ return NO; //YES:允許右滑返回 NO:禁止右滑返回 }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選