SWRevealViewController how to remove swipe gesture

家住魔仙堡 提交于 2019-12-06 22:11:09

问题


I am using good control SWRevealViewController, but by some redone I want to track my own swipe gestures on my screen. So how can I switch off swipe options? I want to work only revealToggle method that attached to my button. Did someone faced with this? Thank you


回答1:


In order to disable the swipe gesture you can simple do:

self.revealViewController.panGestureRecognizer.enabled=NO;

For example:

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.revealViewController.panGestureRecognizer.enabled=NO;
}

-(void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.revealViewController.panGestureRecognizer.enabled=YES;
}



回答2:


In your viewDidLoad method,type the below code where you don't want to enable the swipe gesture:

SWRevealViewController *reveal = self.revealViewController;
reveal.panGestureRecognizer.enabled = NO;



回答3:


I found this method:

for (UIGestureRecognizer *recognizer in self.view.gestureRecognizers) {
    [self removeGestureRecognizer:tap];
}



回答4:


To stop the swipe in the SWRevealViewController:

In Swift 3.0

self.revealViewController().panGestureRecognizer().isEnabled = false


来源:https://stackoverflow.com/questions/22135203/swrevealviewcontroller-how-to-remove-swipe-gesture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!