Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone/iOS: Will there be called any method if a UIView is added as a subview

If I add a view as a subview like so

[self.view addSubview:mySubview];

Will there be called any method on mySubview, that I could override to add some custom behavior?

like image 376
Pascal Klein Avatar asked May 28 '11 14:05

Pascal Klein


People also ask

What method or methods do you call to add a subview to another view?

To add a subview to another view, call the addSubview(_:) method on the superview.

What is a Subview iOS?

A superview is a view that holds other views over it and subviews are the views being held/added over a View.


1 Answers

Adding a view to a (new) superview triggers

- (void)willMoveToSuperview:(UIView *)newSuperview

and

- (void)didMoveToSuperview.

See the UIView Reference for more.

like image 58
Till Avatar answered Nov 06 '22 03:11

Till