How to activate “Installed” programmatically?

旧时模样 提交于 2020-01-01 04:24:28

问题


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.


回答1:


There are two options 1) hide 2) removeFromSuperview.

If You install or uninstall view from storyboard, It 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,

 NSArray *arr = [self.view subviews];
 NSLog(@"arr is %@",arr);

swift:

let array: Array = self.view.subviews
print("Array is \(array)")

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



来源:https://stackoverflow.com/questions/36712036/how-to-activate-installed-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!