How to solve the problem of right slide gesture failure caused by different hidden attributes of the two view controllers navigationBar using navigationController

Source: Internet
Author: User

How to solve the problem of right slide gesture failure caused by different hidden attributes of the two view controllers navigationBar using navigationController

### 1. problem description: for example, A is the rootViewController of navigationController, And the navigationBar is displayed on this page (the hidden attribute is NO). It pushes the stack to the B View Controller, B page navigationBar is not displayed (the hidden attribute is YES), there is A certain probability that it will appear, B needs to slide right to pop itself to stack A, the right slide gesture will become invalid, even if self. navigationController. interactivepopgsturerecognizer. enabled = YES does not work either.
### 2. Problem Analysis: Because the right-sliding gesture is blocked and the gesture still exists, you need to rewrite its proxy method so that the gesture is not blocked.
### 3. Solution steps:
#### 1. Write this line code on page B: self. navigationController. interactivepopgsturerecognizer. delegate = self;

#### 2. Enable page B to comply with the UIGestureRecognizerDelegate Protocol

#### 3. Override the GestureRecognizerDelegate method:
-(BOOL) gestureRecognizerShouldBegin :( UIGestureRecognizer *) gestureRecognizer {
If (self. navigationController. viewControllers. count <= 1 ){
Return NO; // prevents B from having only one page. At this time, the right slide gesture is not used.
}
Return YES;
}

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.