gpt4 book ai didi

ios - 从晚餐 View ios 中删除 View

转载 作者:行者123 更新时间:2023-11-28 19:10:59 24 4
gpt4 key购买 nike

我有一个关于从 supper View 中删除 subview 的问题:现在我有一个名为的 subview :subview1然后我在其他 2 个 View 中添加此 subview :

[supperview1 addSubview: subview1]

[suppertview2 addSubview: subview1]

...我只知道方法removeFromSupperview 从 supperview 中删除一个 subview ,但在这种情况下我想从 supperview1 中删除 subview1 但仍然是 supperview2 的 subview ....我怎么能做吗?

最佳答案

你的代码是错误的。

如果你使用

[supperview1 addSubview: subview1]

然后

[suppertview2 addSubview: subview1]

subview1 只会添加到 suppertview2 上,所以 subview1 只是 suppertview2s subview

苹果说:

Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.

关于ios - 从晚餐 View ios 中删除 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15542089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com