I am using class sizes in interface builder, defining slightly different designs for different sizes.
One of my view is not installed for a specific size. That works as expected, but now I would like to programmatically be able to tell if that view is installed or not. Whether it is installed or not, it looks like the view is never nil, and I can't see any isInstalled flag to check.
What is the correct way to do this?
This isn't a great solution, but I've not found a better one yet:
The docs state that "A runtime object for an uninstalled view is still created. However, the view and any related constraints are not added to the view hierarchy and the view has a superview property of nil".
So a test for a valid superview works as a solution, but I've found that it has to come quite late - in viewDidAppear
. The superviews are still nil in viewWillAppear
, for example.
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