简体   繁体   中英

How do I remove a view from a super view without unloading the superview?

I'm trying to something like [view removeFromSuperview] however when I do it appears from what I've seen and what I've read in the apple documentation that the normal behaviour is to remove the superview from view as well (unless I have misread).

I'm wondering how to simply remove a view from the superview, ie in the case of creating a modal window, then releasing it, and redrawing again later

You are mistaken. Just call:

[subview removeFromSuperview];

Why don't you just try this out? Takes 30 seconds.

You are probably calling removeFromSuperview on the wrong view. It should be called on the view you want to remove, not its superview.

The removeFromSuperview method removes the receiving view from its superview. It does not also remove the receiving view's superview from its superview as you suggest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM