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

荒凉一梦 提交于 2019-12-01 02:50:48

Adding a view to a (new) superview triggers

- (void)willMoveToSuperview:(UIView *)newSuperview

and

- (void)didMoveToSuperview.

See the UIView Reference for more.

You can override these two:

- (void)willMoveToSuperview:(UIView *)newSuperview
- (void)didMoveToSuperview

Take a look in the documentation for UIView for similar methods.

Yes, There is a method which get called if one change the superview . you need to override the below method in your subview class.

- (void)willMoveToSuperview:(UIView *)newSuperview
- (void)didMoveToSuperview

From UIView Doucumentation

willMoveToSuperview:, didMoveToSuperview—Implement these methods as needed to track the movement of the current view in your view hierarchy.

exep for special purpose is far better to customize you view in init phase, you have all you need and (more important) is a synchronous call.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!