Page jump problem, multiple push to new page problem solving method

Source: Internet
Author: User

Today in a sweep of the function, suddenly found several times to click on the sweep of the picture, resulting in a number of trigger taps gesture, on multiple push to the new page, I would like to tap gestures within the push to intercept, but also feel that if there are a lot of places to achieve the solution of the problem is not very troublesome? So think about it, we can solve this problem by rewriting the navigation controller.

Here's how I've written it, and you can directly introduce it into your project to solve a similar problem.

(1), first in the program of a navigation controller class (that is, all the navigation controllers in the program's parent class name is generally: xxxbasenavgationcontroller) extension to follow the agent: Uinavigationcontrollerdelegate ; Write an attribute in the extension

Record push flags for: Resolving from the source, multiple push issues on the page

@property (nonatomic,getter=ispushing) BOOL pushing;

(2), and then set the proxy in the Viewdidload method.

(3), the method of overriding the parent class in the method used for push, the code is as follows:

Overriding the parent class method

-(void ) Pushviewcontroller: (Uiviewcontroller * ) Viewcontroller animated: (BOOL) animated{ //     ~ The following code is to resolve the page's multiple push use ———————————————————— ~  if  (self.pushing == YES) {NSLog ( @ "  was intercepted   );     return  ;  else  @ "  push  "   = YES; }
View Code

(4), the implementation of the navigation controller proxy method, the code is as follows:

// implementation of the proxy method of the navigation controller (in order to solve the problem of multiple push on the page)-(void) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller Didshowviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated{    = NO;    }
View Code

OK, to this point from the root of the implementation of all pages, when push, due to the deft on hand caused by multiple push problem, optimized performance, compared to the button click event to intercept the push method, more advantageous.

Page jump problem, multiple push to new page problem solving method

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.