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

前端 未结 4 1658
情话喂你
情话喂你 2021-01-11 10:23

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

4条回答
  •  旧巷少年郎
    2021-01-11 11:10

    Adding a view to a (new) superview triggers

    - (void)willMoveToSuperview:(UIView *)newSuperview

    and

    - (void)didMoveToSuperview.

    See the UIView Reference for more.

提交回复
热议问题