About customizing the navigation bar, the slide back gesture disappears

Source: Internet
Author: User

Return gesture disappears along with navigation slip

Self.navigationController.navigationBarHidden = YES;

Only disappear navigation

Self.navigationController.navigationBar.hidden = YES;

Navigation controller full Screen slide back effect:

1. The navigation controller's view comes with a swipe gesture, except that the gesture's trigger range is only on the left.

2. When the user drags on the left side of the interface, it will trigger the swipe gesture method, and has the sliding return function, indicating that the system gesture triggering method has realized the sliding return function.

3. Why is the system gesture triggering method already implemented the sliding return function?

Reason:

    • When you create a sliding gesture object, you need to bind the listener and invoke the target action when the gesture is triggered.

Uipangesturerecognizer *pan = [[Uipangesturerecognizer alloc] Initwithtarget:target action:action];
When the user slides to the left of the interface, there is a sliding return function, this is because the trigger gesture, call the target action method, the action method to implement the sliding return function, otherwise there will be no sliding back effect

Navigation Controller Full Screen swipe note points:

1. Disable the system from using sliding gestures.

2. Only the non-root controller of the navigation controller needs to trigger gestures, use gesture proxies, and control gesture triggering.

Full-screen Slide code implementation

-  (void) viewdidload {    [super viewdidload];    //   Get the target object with sliding gestures from the system     id target =  self.interactivepopgesturerecognizer.delegate;    //  Create a full-screen swipe gesture, The action method of the target that calls the system with the swipe gesture     uipangesturerecognizer *pan = [[ Uipangesturerecognizer alloc] initwithtarget:target action: @selector (handlenavigationtransition :)];    //  set gesture proxy, intercept gesture trigger     pan.delegate = self;     //  Add full-screen swipe gesture to the view of the navigation controller     [self.view addgesturerecognizer:pan] ;    //  Disable the use of the system's own sliding gestures      Self.interactivepopgesturerecognizer.enabled = no;}   When to call: The agent is asked before each trigger gesture, whether it is triggered.   Action: Intercept gesture Trigger-  (BOOL) Gesturerecognizershouldbegin: (uigesturerecognizer *) gesturerecognizer{     //  NoteMeaning: Only the non-root controller has the sliding return function, the root controller does not.     //  determine if the navigation controller has only one sub-controller, if there is only one child controller, it must be the root controller     if  ( SELF.CHILDVIEWCONTROLLERS.COUNT == 1)  {        //  Indicates that the user does not need to trigger a swipe gesture on the root controller interface,        return no;     }    return yes;}

About customizing the navigation bar, side-by-side return gesture disappears

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.