check if the view is loaded at run time check if the view is loaded at run time ios ios

check if the view is loaded at run time


If you have an instance of a view controller, you can ask it:

viewController.isViewLoaded


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.


Not quite sure either about your use case, but this might help if you just want to query the view hierarchy.

- (UIView *)viewWithTag:(NSInteger)tag
  1. Tag all the views you are interested in, for ex. tag on certain views of interest; "ImportantView1", "ImportantView2", ...

  2. You need a (parent) view to make the above API call

  3. The call will query the (parent) view and all subviews.

  4. Filter the views by your custom tag name. (if tag starts with "ImportantView")