check if the view is loaded at run time
Solution 1
If you have an instance of a view controller, you can ask it:
viewController.isViewLoaded
Solution 2
I'm not entirely clear on what you mean by "loaded." Depending on your definition of "loaded" you could:
Check if the view is
nil
(the broadest definition of loaded, though this will depend on someone nilling out the view when it is deallocated, lest you get an EXC_BAD_ACCESS).Check
[view superview]
to see whether the view has a superview.Check
[view window]
to see whether a view is part of a window (a prerequisite for being "on screen")Assuming there is a corresponding UIViewController, query the controller's
isViewLoaded
property to see whether it has loaded a view into memory. This particularly helps with view life cycle issues.
There are probably other interpretations of "loaded" and other things you can check, but these are the first things off the top of my head.
Related videos on Youtube
ramo
Updated on June 04, 2022Comments
-
ramo almost 2 years
Is there any way that I could see a view is loaded without checking the source code of that view controller (e.g., viewDidLoad, viewWillAppear, etc.)
or how can I check at the run time / dynamically if any view is loaded to grab the subviews.
-
ramo about 12 yearsthen where should I check this and check isViewLoaded. So firt the applicationDidFinishLaunching is called and then the viewdidload of the first view is called. where can I check isViewLoaded