Ios7 -- the system's built-in sliding to the right gesture returns the previous interface, ios7 -- gesture

Source: Internet
Author: User

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.