简体   繁体   English

如何在不卸载超级视图的情况下从超级视图中删除视图?

[英]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). 我正在尝试类似[view removeFromSuperview]但是从我所看到的内容以及我在Apple文档中阅读的内容来看,正常行为是也从视图中删除了Superview(除非我有误解)。

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. 需要30秒。

You are probably calling removeFromSuperview on the wrong view. 您可能在错误的视图上调用removeFromSuperview It should be called on the view you want to remove, not its superview. 应该在要删除的视图上调用它, 而不是在其父视图上调用它。

The removeFromSuperview method removes the receiving view from its superview. removeFromSuperview方法从其超级视图中删除接收视图。 It does not also remove the receiving view's superview from its superview as you suggest. 它不会从它的父,你也建议删除该接收视图的上海华。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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