Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is willMoveToSuperview called (with nil) when removing a view from a hierarchy?

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.

like image 607
jhabbott Avatar asked Nov 26 '11 23:11

jhabbott


1 Answers

Whenever a view receives removeFromSuperview, and the view's superview was not already nil, the view will always do [self willMoveToSuperview:nil].

like image 145
rob mayoff Avatar answered Nov 17 '22 23:11

rob mayoff