@interfaceViewcontroller () <uigesturerecognizerdelegate>@[email protected]Viewcontroller- (void) viewdidload {[Super viewdidload]; //Custom Back buttonUIButton *button = [[UIButton alloc]initwithframe:cgrectmake (0,0, -, -)]; [Button Settitle:@"Wang Yu 2"Forstate:uicontrolstatenormal]; [Button Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal]; [Button addtarget:self action: @selector (back:) forcontrolevents:uicontroleventtouchupinside]; Self.navigationItem.leftBarButtonItem=[[Uibarbuttonitem Alloc]initwithcustomview:button];} - (void) Back: (UIButton *button {[Self.navigationcontroller popviewcontrolleranimated:yes];}- (void) Viewwillappear: (BOOL) animated {[Super viewwillappear:animated]; if(Self.navigationController.viewControllers.count >1) {//the agent that records the system return gesture_delegate = Self.navigationController.interactivePopGestureRecognizer.Delegate;//set the system return gesture for the agent for the current controllerSelf.navigationController.interactivePopGestureRecognizer.Delegate=Self ; }} - (void) Viewwilldisappear: (BOOL) animated {[Super viewwilldisappear:animated]; //The agent that sets the system return gesture is the return gesture agent for the system that we recorded when we first entered the controller .Self.navigationController.interactivePopGestureRecognizer.Delegate=_delegate;}#pragmamark-uigesturerecognizerdelegate-(BOOL) Gesturerecognizershouldbegin: (Uigesturerecognizer *) GestureRecognizer {R Eturn self.navigationController.childViewControllers.count > 1;} -(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) Othergesturerecognizer {returnSelf.navigationController.viewControllers.count >1;}@end
The 26th article, because the custom item (NAV), so that the system right-slide return gesture invalidation solution