Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens when an UIView is added to another UIView twice in IOS?

Tags:

ios

uiview

What happens when an UIView is added to another view twice in iOS? I believe it wont get added twice. Have anyone ever tried?

like image 244
RK- Avatar asked Dec 15 '11 15:12

RK-


2 Answers

[UIView addSubview:] documentation

Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.

like image 133
Sulthan Avatar answered Nov 15 '22 21:11

Sulthan


A view can only have one parent view. But a view can have many subviews.

Read the Documentation of UIView.

Specifically read about addSubView

like image 25
Joze Avatar answered Nov 15 '22 19:11

Joze