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?
The superview is the immediate ancestor of the current view. The value of this property is nil when the view is not installed in a view hierarchy. To set the value of this property, use the addSubview(_:) method to embed the current view inside another view.
Answer. SuperView allows you to capture an immersive wide angle perspective. What this mode does is it takes a 4:3 aspect ratio and dynamically stretches it to a 16:9 aspect ratio.
A Subview is any View that is the child of another View. You can create a hierarchy with any number of Subviews. For example, the top level View you can have is the My Network View. Beneath this you might want to create a View called Device Types.
"receiver" is a throwback to the days of objective-c when "messages" were sent to "objects". So us old people (hah) used to call [someView addSubview:anotherView] instead of someView. addSubview(anotherView) . In that scenario, "someView" is the receiver because it's RECEIVING the "addSubview" message.
A superview is a view that holds other views over it and subviews are the views being held/added over a View.
Let's assume we have a view named MyView, which holds a UIButton (named loginButton) over it. Here MyView is considered a superview for loginButton and loginButton is considered a subview of MyView.
For more, you should start from here
As per the provided code snippet.
[self.view addSubview:self.frontView];
Hence view (Controller's view) is a superview and frontView is a subview
"superview" means the view which holds the current one. "subviews" means the views which are holding by the curent view.
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.
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