UIKit Lifecycle
[iOS UIKit]:: viewIsAppearing
New viewIsAppearing Callback in View Lifecycle
Apple added a new view controller lifecycle callback viewIsAppearing
in iOS 17 that’s back-deployable to iOS 13. Hence, there is no need to wait until you can require iOS 17 to adopt the new API.
viewIsAppearing
is the most suitable place to perform tasks that depend on the view’s size or trait collection.
The viewIsAppearing
is called after viewWillAppear
but before viewDidAppear
. The key difference is that it’s called after the view has been added to the hierarchy but is not yet onscreen. The view controller’s view has been laid out so you can rely on its size and traits.
Note:
- This new callback can be called multiple times like viewWillAppear if the view appears more than once.
- Calls only once during the appearance transition unlike
viewWillLayoutSubviews()
andviewDidLayoutSubviews()
which can called multiple times during the transition.
References:
- Apple WWDC 2023 documentation
Make sure you give this post 50 claps 👏 and follow if you enjoyed reading and want to read and learn more.
Thank you for reading. ❤️
Connect with me: LinkedIn
Keep Learning. Keep Sharing.