turushan turushan - 2 years ago 123
Swift Question

How to activate "Installed" programmatically?

This is an UIView and I want to activate it (with its constraints etc.) when I want, how to do that? I don't want removefromsuperview etc. just want to learn this "Installed" function exact equivalent in terms of code.

enter image description here

Answer Source

There are two options 1) hide 2) removefromSuperview.

If You install or uninstall view from storyboard is equivalent to add/remove view.

refer this apple documentation it says,

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. This is different from being hidden. A hidden view is in the view hierarchy along as are any related constraints.

you can check this by two line of code,

 //convert in swift !!
 NSArray *arr = [self.view subviews];
 NSLog(@"arr is %@",arr);

try it with installed and uninstalled. hope this will help :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download