8 9 first, the gesture right slide return effect is invalidTen One In the app that we used to use, we used to go right back to this effect, but I found that this function in our app is invalid, only click the Back button in the upper left corner to perform this effect. Later, we found out that the cause of this problem is that we have customized the Leftbarbuttonitem in the upper left corner, and we have customized this barbuttonitem so that the system cannot capture pop gestures. A - Workaround: - theCreate a subclass of Uinavigationcontroller Lgjbasenavcontroller, the class@interfaceLgjbasenavcontroller (), all operations on the navigation controller are operated within this class. - - 1The delegate of the set gesture is self, and the delegate of the navigation controller is self. - +- (void) Viewdidload { - [Super Viewdidload]; + A__weak Lgjbasenavcontroller *weakself =Self ; at if([Self respondstoselector: @selector (Interactivepopgesturerecognizer)]) { -Self.interactivepopgesturerecognizer.Delegate=weakself; -Self.Delegate=weakself; - } - } - in-(Uiviewcontroller *) popviewcontrolleranimated: (BOOL) Animated { - return[Super popviewcontrolleranimated:animated]; to } + 2In the transition/when the transition is disabled interactivepopgesturerecognizer when the user triggers a back gesture during the transition, it is easy to wake up with various other events, the navigation stack, or the edge clutter. Then disable gesture recognition during the transition effect, and then enable the new view controller when it has finished loading. - the #pragmaMark-uinavigationcontrollerdelegate *- (void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) Animated { $ if([Self respondstoselector: @selector (Interactivepopgesturerecognizer)]) {Panax Notoginsengself.interactivePopGestureRecognizer.enabled =NO; - } the //Set Back button + if(Self.viewControllers.count >0) { AViewController.navigationItem.leftBarButtonItem =[self backbuttonitem]; the } + [Super Pushviewcontroller:viewcontroller animated:animated]; - } $ $- (void) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller Didshowviewcontroller: (UIViewController *) Viewcontroller animated: (BOOL) Animated { - if([Self respondstoselector: @selector (Interactivepopgesturerecognizer)]) { -self.interactivePopGestureRecognizer.enabled =YES; the } - }Wuyi 3causes the first controller in the Navigationcontroller to not respond to a right-slip pop gesture the --(BOOL) Gesturerecognizershouldbegin: (Uigesturerecognizer *) Gesturerecognizer { Wu if([self.childviewcontrollers count] = =1) { - returnNO; About } $ returnYES; - } - 4resolve multiple gesture conflicts and accept multiple gestures simultaneously - A-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) Othergesturerecognizer { + returnYES; the } - 5solve when the finger slips, the uiscrollview in the viewcontroller of the pop will scroll along $ the-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldberequiredtofailbygesturerecognizer: ( Uigesturerecognizer *) Othergesturerecognizer { the return[Gesturerecognizer Iskindofclass:uiscreenedgepangesturerecognizer.class]; the } the There are several similar gesture proxy methods for this approach to handle complex gesture collisions: - in //Touch the screen after the callback method, return no is no longer gesture recognition, method trigger, etc. the-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldreceivetouch: (Uitouch *) Touch; the //method to invoke when gesture recognition is started, return no to end, no longer trigger gesture About-(BOOL) Gesturerecognizershouldbegin: (Uigesturerecognizer *) Gesturerecognizer; the //whether to support multi-time triggering, return yes, you can trigger the method with multiple gestures, return no is mutually exclusive the-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) Othergesturerecognizer; the //The following two methods are also used to control the mutex execution of a gesture . + //This method returns Yes, when the first gesture and the second mutex are invalidated by the first one. --(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrequirefailureofgesturerecognizer: ( Uigesturerecognizer *) Othergesturerecognizer Ns_available_ios (7_0); the //This method returns Yes, the first and second mutually exclusive, and the second one is invalidated.Bayi-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldberequiredtofailbygesturerecognizer: ( Uigesturerecognizer *) Othergesturerecognizer Ns_available_ios (7_0); theThese methods can be written in a Uinavigationcontroller subclass, and then set self.window.rootViewController in Appdelegate =[[Lgjbasenavcontroller alloc] initwithrootviewcontroller:vc1]; can handle the global navigation controller The problem of the return of the right slip gesture, I write these methods directly on the inside can be. In addition, you can set some custom styles for the navigation bar in this lgjbasenavcontroller: for example, this style can be set in Lgjbasenavcontroller initialization: the - 668737-E1c9f390f405bd70.png - the Navbar.png the the the+ (void) Initialize { - the //Bar Style theUinavigationbar *bar =[Uinavigationbar appearance]; the [Bar Setbarstyle:uibarstyledefault];94 [Bar Setbartintcolor:[uicolor Blackcolor]; the the [Bar Settitletextattributes:[nsdictionary Dictionarywithobjectsandkeys:[uicolor Whitecolor], Nsforegroundcolorattributename, Nil]]; the 98 //Barbutton Style AboutUibarbuttonitem *item =[Uibarbuttonitem appearance]; - 101 //Normal102Nsmutabledictionary *textatts =[Nsmutabledictionary dictionary];103Textatts[nsforegroundcolorattributename] =[Uicolor Orangecolor];104Textatts[nsfontattributename] = [Uifont systemfontofsize: -]; the [item Settitletextattributes:textatts forstate:uicontrolstatenormal];106 107 //Unavailable State108Nsmutabledictionary *disabletextatts =[Nsmutabledictionary dictionary];109Disabletextatts[nsforegroundcolorattributename] = [Uicolor colorwithred:123/255.0Green123/255.0Blue123/255.0Alpha1]; theDisabletextatts[nsfontattributename] = [Uifont systemfontofsize: -];111 [item Settitletextattributes:disabletextatts forstate:uicontrolstatedisabled]; the }113 second, hidden Navigationbar return, there will be vacancies the theThis should also be the effect that we often see, such as VC1 jump VC2,VC2 navigation bar is hidden, when returning from VC2 VC1, in this process, slowing down to see there will be missing a piece, put a quick look is a splash screen, this effect on the user is not friendly, this solution is relatively simple. This is when setting Setnavigationbarhidden in the secondary Viewcontroleller: < important is the animated parameter in the back > the 117 118- (void) Viewwillappear: (BOOL) Animated {119 [Super viewwillappear:animated]; - [Self.navigationcontroller setnavigationbarhidden:yes animated:animated];121 }122 123- (void) Viewwilldisappear: (BOOL) Animated {124 [Super viewwilldisappear:animated]; the [Self.navigationcontroller setnavigationbarhidden:no animated:animated];126 }
iOS navigation issues