Ios7 -- the system's built-in sliding to the right gesture returns the previous interface, ios7 -- gesture
When pushing from Controller A to Controller B, we return Controller A, in addition to using the button to return
[self.navigationController pushViewController:Vc animated:YES];
You can also use ios7 to slide to the right and return to Controller.
This is defined in the document as follows:
@property(nullable, nonatomic, weak) id<UINavigationControllerDelegate> delegate;@property(nullable, nonatomic, readonly) UIGestureRecognizer *interactivePopGestureRecognizer NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;
----------------------------------------------------------------------
In viewDidLoad of controller B
If ([[[UIDevice currentDevice] systemVersion] floatValue]> = 7.0) {self. navigationController. interactivepopgsturerecognizer. enabled = YES; // valid set of gesture to YES is invalid as NO self. navigationController. interactivepopgsturerecognizer. delegate = self; // set the gesture proxy to self}
However, when Controller A is returned, if you want to push it to Controller B, the screen will appear and the screen will not be moved, because rootView will also have the problem of sliding back to the right.
To solve this problem, we only need to set interactivepopgsturerecognizer to NO in viewDidAppear of controller:
-(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; }}
In this way, you can slide to the right of B to ensure that the pushB is not stuck on the interface again after A is returned.