简体   繁体   English

你有一个视图可以作为iPhone的几个不同视图的子视图吗?

[英]Can you have one view be a subview for several different views for iPhone?

Is it possible to add the same view instance as a subview of two different views at the same time? 是否可以同时添加相同的视图实例作为两个不同视图的子视图? I'm trying to do this but it only shows up on the last one it was added as a subview to. 我正在尝试这样做,但它只显示在最后一个它作为子视图添加到。

No, a view can only be in a single view hierarchy at a time. 不,视图一次只能位于单个视图层次结构中。 If you add it to another view, it will automatically be removed from its previous view. 如果将其添加到另一个视图,它将自动从其先前视图中删除。 Also, if you add it to the same view that it was already in, it will automatically be removed and re-added as the top-most item (however, this is much less efficient than just simply changing its position directly). 此外,如果您将其添加到它已经存在的同一视图中,它将自动删除并重新添加为最顶层的项目(但是,这比仅仅直接更改其位置效率低得多)。

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

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