从另一个子视图的内部和下方添加子视图(Add a subview from within and below another subview)

编程入门 行业动态 更新时间:2024-10-22 08:06:30
从另一个子视图的内部和下方添加子视图(Add a subview from within and below another subview)

在iOS应用中,我在主视图中添加了一个子视图:

[self.view addSubview:firstUIImageSubview];

但是在子视图类firstUIImageSubview中,我正在创建并添加另一个我希望放在第一个子视图下面的子视图(secondUIImageSubview):

[self insertSubview:secondUIImageSubview belowSubview:self];

我的问题是第二个子视图显示在第一个子视图上方,当我想在下面。 怎么可能实现这一目标? 谢谢。

In an iOS app, I am adding a subview to my main view with:

[self.view addSubview:firstUIImageSubview];

However in the subview class firstUIImageSubview, I am creating and adding another subView (secondUIImageSubview) that I would like to put below the first subview with:

[self insertSubview:secondUIImageSubview belowSubview:self];

My problem is that the second subview is displayed above the first subview when I want to have it below. How is it possible to achieve that ? Thanks.

最满意答案

这应该可以解决问题。

[self.superview insertSubview:secondUIImageSubview atIndex:0];

This should do the trick.

[self.superview insertSubview:secondUIImageSubview atIndex:0];

更多推荐

本文发布于:2023-07-16 07:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1125481.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   个子   subview   Add

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!