Appearing and Disappearing Views
UIViewController has several methods that get called at certain times:
- viewWillAppear:
when its view is about to be added to the window
- viewDidAppear:
when its view has been added to the window
- viewWillDisappear:
when its view is about to be dismissed, covered, or otherwise hidden from view
- viewDidDisappear:
when its view has been dismissed, covered, or otherwise hidden from view
These methods are useful because a view controller is only created once, but its view usually gets displayed (and dismissed or hidden) several times. You often need a way to override the default behavior at these times in the life of view controller. For example, you may want to do some sort of initialization each time the view is moved on ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access