从另一个子视图的内部和下方添加子视图(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];更多推荐
发布评论