Viewcontroller life cycle and interactivepopgesturerecognizer those things

Source: Internet
Author: User

Viewcontroller life cycle

Viewwillappear, Viewdidappear, Viewdidload, Loadview, Initwithnibname, Alloc, Dealloc, Ear, viewdiddisappear

Note that Viewwillunload and viewdidunload have been abandoned in IOS6 because clearing references to the views are no longer necessary.

Note 1. No viewwillload.

Note that 2.viewDidLoad and viewdidunload are not paired.

The method invocation process in some cases:

  •   pushviewcontroller and   presentviewcontroller   Method The transition from a-view controller to B-View controller, which triggers the Span style= "color: #0000ff;" > (a) viewwilldisappear-> (B) viewwillappear-> (a) viewdiddisappear-> (B) Viewdidappear
  • Right-slip return gesture, Popviewcontroller, and dismissviewcontrolleranimated method Implementation of the B-View Controller Transitions to a view controller are triggered sequentially (b) viewwilldisappear-> (a)viewwillappear-> (b)viewdiddisappear-> (a) Viewdidappear

Right slide Exit Event statistics:

Right-swipe trigger viewwilldisappear may be exited, or may not exit, while clicking Return exit and right-swipe exit will trigger Viewdiddisappear, which requires the transition coordinator (

uiviewcontrollertransitioncoordinator)

-(void) Viewwilldisappear: (BOOL) animated{

[Super viewwilldisappear:animated];

if ([Self.navigationcontroller respondstoselector: @selector (interactivepopgesturerecognizer)])

{

Id<uiviewcontrollertransitioncoordinator> TC = Self.navigationController.topViewController.transitionCoordinator;

[TC notifywheninteractionendsusingblock:^ (id<uiviewcontrollertransitioncoordinatorcontext> context) {

//The interactive transition operation ends the code block of the call, and the right-hand end (regardless of whether the pop succeeds), if unsuccessful, will call Viewwillappear after this block of code ends

_interactivepopexit = YES; //global variable, yes indicates the right slip exits successfully, no indicates failure

}];

}

}

-(void) Viewwillappear: (BOOL) animated{

[Super viewwillappear:animated];

_interactivepopexit = NO; //Right Slide exit operation failed Pop

}

-(void) Viewdiddisappear: (BOOL) animated{

[Super viewdiddisappear:animated];     

if (_interactivepopexit) {

NSLog (@ "Edge right slide Exit");

}

}

Viewcontroller life cycle and interactivepopgesturerecognizer those things

Related Article

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.