SoFunction
Updated on 2025-04-12

iOS push side-sliding return function implementation method

This article shares the specific code of iOS push side-sliding return function for your reference. The specific content is as follows

Turn on the slide return function of push that comes with iOS (only the left edge area responds to slide back, not the global response):

- (void)viewWillAppear:(BOOL)animated
{
 [super viewWillAppear:animated];
 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
  [ setEnabled:YES];
   = self;
 }
}

To prevent the navigation controller from triggering gestures when the root view

- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer {
 if ( == 1) {
  return NO;
 } else {
  return YES;
 }
}

In this way, the return operation is swiped to the root view, and then the push will have no effect, and the interface will be stuck; the code has pushed to the next VC, but the interface is still stuck in the root view.

SolutionAdd the following code to the root view:

-(void)viewDidAppear:(BOOL)animated{
 [super viewDidAppear:animated];
 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
   = NO;
 }
}

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.