The 26th article, because the custom item (NAV), so that the system right-slide return gesture invalidation solution

Source: Internet
Author: User

@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

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.