当从层次结构中删除视图时,是否会调用willMoveToSuperview(使用nil)? [英] Is willMoveToSuperview called (with nil) when removing a view from a hierarchy?
问题描述
如果您在 UIView
子类中实现 willMoveToSuperview
,则会保证被调用(<$ c $在您的视图中调用 removeFromSuperview
时,
newSuperview
参数可以为 nil
,并且称为超看更改,但我不确定是否可以解释这意味着当视图从其超级视图中删除时,即使没有移动到不同的超级视图,它将被调用。每当视图接收到 removeFromSuperview
,并且视图的superview不是nil, [self willMoveToSuperview:nil]
。
If you implement willMoveToSuperview
on a UIView
subclass, is it guaranteed to be called (with nil
) when removeFromSuperview
is called on your view?
The docs say that the newSuperview
parameter may be nil
and that it's called "whenever the superview changes" but I'm not sure if I can interpret this to mean it will be called when the view is removed from its superview even when not being moved to a different superview.
Whenever a view receives removeFromSuperview
, and the view's superview was not already nil, the view will always do [self willMoveToSuperview:nil]
.
这篇关于当从层次结构中删除视图时,是否会调用willMoveToSuperview(使用nil)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!