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