Apple says:
removeFromSuperview Unlinks the receiver from its superview and its window, and removes it from the responder chain.
- (void)removeFromSuperview
Never invoke this method while displaying.
So, when I want to get rid of a view, I was used to just kick it off from it's superview. Why should I never invoke that while it's visible? So I must set it to hidden=YES before I do that?
If the view's superview is not nil , the superview releases the view. Calling this method removes any constraints that refer to the view you are removing, or that refer to any view in the subtree of the view you are removing.
The specification specifies "while displaying" not "while it is on display". Thus, you should never call removeFromSuperview
in the view's drawRect
for example.
removeFromSuperview
releases the view and may deallocate it. The parent view when attempting to display the view may not expected it to be deallocated and cause a corrupted access.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With