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