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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以,一个视图一次只能位于一个视图层次结构中。如果将其添加到另一个视图,它将自动从之前的视图中删除。另外,如果您将其添加到它已经存在的相同视图中,它将自动被删除并重新添加为最顶层的项目(但是,这比简单地更改要低得多)直接其位置)。
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).