8

In iOS apps, there is a default gesture that swipe from the left edge to right the app navigationController will pop view controller.

But is there a way to disable it for specific view?

bohan
  • 1,659
  • 3
  • 17
  • 29
  • iOS Apps changing default gesture actions will not be accepted to the App Store – Cilan Jan 02 '14 at 05:54
  • 1
    Look at this [question](http://stackoverflow.com/questions/19108601/how-to-disable-back-gesture-in-ios-7-for-only-one-view). This may help you. – Akhilrajtr Jan 02 '14 at 06:00
  • possible duplicate of [How to disable back swipe gesture in UINavigationController on iOS 7](http://stackoverflow.com/questions/17209468/how-to-disable-back-swipe-gesture-in-uinavigationcontroller-on-ios-7) – idmean Aug 09 '14 at 18:17

3 Answers3

29

You can disable it through the public API, See UINavigationController Class Reference

  //iOS7 Customization, swipe to pop gesture
  if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
      navigationController.interactivePopGestureRecognizer.enabled = NO;
  }

Also, you can switch back to previous state when needed

Bilal Saifudeen
  • 1,677
  • 14
  • 14
2
if(navigationController) {
  if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
    navigationController.interactivePopGestureRecognizer.enabled = NO;
  }
}
VMAtm
  • 27,943
  • 17
  • 79
  • 125
0

its possible but may be a cause for you app rejection

-(void) viewWillAppear:(BOOL)animated 
{
    [super viewWillAppear:animated];
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
Retro
  • 3,985
  • 2
  • 17
  • 41