Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 disable the swipe back

Tags:

ios

gesture

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?

like image 725
bohan Avatar asked Jan 02 '14 05:01

bohan


2 Answers

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

like image 123
Bilal Saifudeen Avatar answered Oct 04 '22 08:10

Bilal Saifudeen


if(navigationController) {
  if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
    navigationController.interactivePopGestureRecognizer.enabled = NO;
  }
}
like image 34
Abdul Rahman Khan Avatar answered Oct 04 '22 10:10

Abdul Rahman Khan