当前位置: 移动技术网 > IT编程>移动开发>IOS > iOS禁用右滑返回的两种方法

iOS禁用右滑返回的两种方法

2019年07月24日  | 移动技术网IT编程  | 我要评论

魔芋荷叶粥,阳新二手房,段霖夏

本文实例为大家分享了ios禁用右滑返回的具体代码,供大家参考,具体内容如下

方式一:

前提:如果使用的自定义uinavigationcontroller基类,请不要在此基类里写相关的手势操作方法。

代码如下:

-(void)viewdidappear:(bool)animated{ 
  if ([self.navigationcontroller respondstoselector:@selector(interactivepopgesturerecognizer)]) { 
    self.navigationcontroller.interactivepopgesturerecognizer.enabled = no; 
  } 
} 
   
-(void)viewwilldisappear:(bool)animated{ 
  self.navigationcontroller.interactivepopgesturerecognizer.enabled = yes; 
} 

方式二:

流程:先设置代理---->重写手势操作方法

-(void)viewdidappear:(bool)animated{ 
  self.navigationcontroller.interactivepopgesturerecognizer.delegate = self; 
} 
   
- (bool)gesturerecognizershouldbegin:(uigesturerecognizer 
                   *)gesturerecognizer{ 
  return no; //yes:允许右滑返回 no:禁止右滑返回 
} 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网