Whenever we present
or push
from SourceViewController
to DestinationViewController
, ViewDidLoad()
method called every time in DestinationViewController
in xCode 9.4
and iOS 11
or later. And when we pop or dismiss from DestinationViewController
to SourceViewController
, viewDidLoad()
method not called.
ViewDidload method only called only when the view loads first time. When you present or push it loads the view so, it calls viewdidload. But when you pop it release the view.
Here is the lifecycle of UIViewController
.
ViewDidLoad
- Called when you create the class and load from xib. (Either present or push) This method called for initial setup and only one time called. ViewWillAppear
- Called right before your view appears, this will be called every time your view is about to appear on the screen. ViewDidAppear
- Called after the view appears - great place to start an animations or the loading of external data from an API. This will be also called every time after ViewWillAppear
when view appeared on the screen. ViewWillDisappear/DidDisappear
- Same idea as ViewWillAppear/ViewDidAppear only when view is about to dismiss or pop. ViewDidUnload/ViewDidDispose
- In Swift or Objective C, this is where you do your clean-up and release of stuff, but this is handled automatically so not much you really need to do here. Read Apple documentation for details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.