如何激活“已安装”编程? [英] How to activate "Installed" programmatically?
问题描述
这是 UIView
,我想激活它(带有约束等),当我想要时,该怎么做?我不想 removefromsuperview
等。只是想学习这个已安装的
函数完全等同于代码。
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)隐藏
2) removefromSuperview
。
There are two options 1) hide
2) removefromSuperview
.
如果您安装
或从
视图,相当于 storyboard
中卸载添加/删除
视图。
请参阅苹果文档它说,
仍然创建了卸载视图的运行时对象。但是,视图和任何相关约束不会添加到视图层次结构中,并且视图的superview属性为nil。这与隐藏不同。隐藏视图在视图层次结构中与任何相关约束一样。
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 :)
这篇关于如何激活“已安装”编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!