xcode ( iOS ) 什么是超级视图,什么是子视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13123306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
( iOS ) What is superview and what is subviews
提问by Edward Anthony
What is superview and what is subviews?
什么是超级视图,什么是子视图?
When I add this code:
当我添加此代码时:
[self.view addSubview:self.frontView];
// what does that mean ?
And...
和...
@property (nonatomic, strong) IBOutlet UIImageView *frontView;
[self.frontView superview] != nil // means ?
what is in superview?
什么是超级视图?
回答by Kamar Shad
A superview
is a view which holds other views over it. subviews
are the views being held/added over a 'View'.
Asuperview
是一个视图,它持有其他视图。subviews
是在“视图”上持有/添加的视图。
Lets say you have a view called MyView
, which has a UIButton
(loginButton) over it. In this case, MyView
is a superview
for loginButton
and loginButton
is a subview of MyView
.
假设您有一个名为 的视图MyView
,上面有一个UIButton
(loginButton)。在这种情况下,MyView
是superview
forloginButton
并且loginButton
是 的子视图MyView
。
回答by Ivan Surzhenko
"superview" means the view which holds the current one. "subviews" means the views which are holding by the curent view.
“superview”是指保存当前视图的视图。“子视图”是指当前视图所持有的视图。
For example, you have a view (will call it as MyView) which include a button. Button is a view too (UIButton is a kind of view). So, MyView is superview for the button. Button is a subview for MyView.
例如,您有一个包含按钮的视图(将其称为 MyView)。Button 也是一个视图(UIButton 是一种视图)。所以,MyView 是按钮的超级视图。Button 是 MyView 的子视图。
回答by trojanfoe
See Apple's View Programming Guide, section View Hierarchies and Subview Management
参见 Apple 的View Programming Guide,部分View Hierarchies 和 Subview Management
回答by abhishekkharwar
subview is childview ( which is added on any view)
子视图是子视图(添加到任何视图上)
superview is parentview (on which subview is added)
超级视图是父视图(在其上添加子视图)