SoFunction
Updated on 2025-03-01

Example of IOS Development Notes Disable Gesture Slide Return Function

After iOS7, Apple launched the gesture swipe return function, that is, swipe from the left side of the screen to the right to return to the previous interface. This function is convenient for users in most cases, but sometimes, we do not need a gesture return function. For example, a certain page has added a left-right sliding page turn function, so users can easily return to the previous interface when using it.

To disable the sliding return gesture, you need to add the following code to the ViewController of the change interface:

- (void)viewDidAppear:(BOOL)animated 
{ 
  [super viewDidAppear:animated]; 
  // Disable the return gesture  if ([ respondsToSelector:@selector(interactivePopGestureRecognizer)]) { 
     = NO; 
  } 
} 

If the interface only disables the sliding return gesture, you also need to add the following code to enable other interfaces to continue using the sliding return gesture:

- (void)viewWillDisappear:(BOOL)animated 
{ 
  [super viewWillDisappear:animated]; 
  // Turn on the return gesture  if ([ respondsToSelector:@selector(interactivePopGestureRecognizer)]) { 
     = YES; 
  } 
} 

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.