bohan
bohan

Reputation: 1699

iOS 7 disable the swipe back

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?

Upvotes: 8

Views: 8182

Answers (3)

Abdul Rahman Khan
Abdul Rahman Khan

Reputation: 262

if(navigationController) {
  if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
    navigationController.interactivePopGestureRecognizer.enabled = NO;
  }
}

Upvotes: 2

Bilal Saifudeen
Bilal Saifudeen

Reputation: 1677

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

Upvotes: 29

Retro
Retro

Reputation: 4005

its possible but may be a cause for you app rejection

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

Upvotes: 0

Related Questions