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?
The specification specifies “while displaying” not “while it is on display”. Thus, you should never call
removeFromSuperviewin the view’sdrawRectfor example.removeFromSuperviewreleases 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.