I always thought that viewDidAppear
was called whenever your view appeared on the screen, but I've been told that, for example, when you background an app (by pressing home button) and then bring it back up, viewDidAppear
is not called (going to background "doesn't remove the current view from the view hierarchy"). So, what does it actually mean for a view to "appear"? Also, what does it mean for a view to "load", ie. when does it actually happen (for example, when the app is opened by touching the app icon, etc.)

- 2,452
- 3
- 28
- 45
-
An easy way to get a better understanding is to add nslog statements in a view controller and take a look at the output. – trydis Apr 15 '16 at 07:18
-
Just go through this: http://stackoverflow.com/questions/5630649/what-is-the-difference-between-viewwillappear-and-viewdidappear – Akash KR Apr 15 '16 at 07:25
3 Answers
Is Heirarchy Of this:- Alwys Whenevr Your View Controller Runs It Go Like This
1st ViewDidLoad
2nd ViewAppear
3rd ViewDidAppear
4th ViewWillDisAppear
5th ViewDidDisAppear
Last 6th ViewDidUnload
You Can Understand This by This Simple Life Example :-
Suppose You Are In Cafe And
1st==> You Ordered Coffee Then Service Here Your Call Then They Fill Your Coffee On The Cup (Note Loading Or Filling All Contain Like Coffee on Cup Is Called ViewDidLoad )
2nd==>> And When Service Put Coffee On Your Table (Note Is Called ViewWillAppear Where Your Coffee just Like Your ViewController View )
3rd==>> And When You See Your Coffe (Note Is Called ViewDidAppear Where Your View Can See On Your Screen Just Like When Your See Your Coffee )
4th==>> After That When You Finished Your Macachino Coffee And is Empty (Note is Called ViewWillDisAppear Where Unloading or Proccess Of Empty is Stands For ViewWillDisAppear )
5th & 6th==>> And After That When Service Came And It's Pick Up Your Coffee Cup And Take Back From You When Is Did Disappear From Your Eyes (Note is Called ViewDidDisAppear When View or Your Screen Is Go Blank Just Like Your Cup ) And Finally All Proccesss Done Here....
And If You Again ordered Diff. Coffee Aur Same Coffee That All Step Called Again Same Like That, You Have Multiple ViewController And They Call Again Again A--B--A--B
Thx For Listing This Story Happy Coding

- 284
- 1
- 17
viewDidLoad
is called when all outlets are initialized from a Storyboard.
viewDidAppear
calls when a View Controller is added to another view controller hierarchy. Usually after all animations is finished, but not necessary.
If you implement custom controller which will contain some child view controllers, you will call didMoveToParentViewController
of the child controllers when they are added to the parent. So, whenever you call this method viewDidAppear
of child VC's will be called automatically.

- 11,323
- 6
- 67
- 104
viewDidLoad
is called after your view is loaded. It is called only once when view is initialized and pushed or presented.
viewDidAppear
is called once you see the loaded view on screen. It is called after view appeared.
ViewDidAppear
is called everytime when you see the view after it is loaded. if you push and then pop any other viewController on that view then again viewDidAppear
gets called.
Lifecycle of view Controller:
- ViewDidLoad
- ViewWillAppear
- ViewDidAppear

- 2,004
- 1
- 13
- 21
-
Not entirely true. viewWillAppear is not called when a popover modal ViewController above the current ViewController is popped. – Dave Nov 03 '20 at 02:49