Is there a BOOL or some other way of knowing if viewDidLoad: has been called?
I need to change a view property every time my view has entered active, but if the view hasn't ever been loaded, I don't want to prematurely trigger viewDidLoad:. If there isn't way of easily telling if viewDidLoad: has been called, I'll simply add a BOOL called loaded set to NO in the view controller init, then change the view properties after entered active if loaded is YES or in viewWillAppear: if loaded is NO then set loaded to YES.
viewDidLoad() is one of the initialization methods that is called on the initial view controller. viewDidLoad() is called before anything is shown to the user - and it is called only once.
viewDidLoad() Called after init(coder:) when the view is loaded into memory, this method is also called only once during the life of the view controller object. It's a great place to do any view initialization or setup you didn't do in the Storyboard.
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.
Yes viewdidload: is called before viewWillAppear:. and The apple developer guide says this method gets called after the view is loaded into memory means, The viewController in storyboard/XIB is loading into device memory.
Use isViewLoaded
. Other than that it does exactly what you want, there's not that much to say about it. The documentation is as simple as:
Calling this method reports whether the view is loaded. Unlike the view property, it does not attempt to load the view if it is not already in memory.
Perhaps you should init your UIView in viewDidLoad
, and then change it in whichever way you need to inside viewWillLayoutSubviews
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With