带来SubviewToFront问题?
你好, 我有父视图-->多个子视图。 当我在父视图中使用 [self BringSubviewToFront:childview] 时,它工作正常。但是在将孙子视图添加到子视图之后,当我使用 [self BringSubviewToFront: grandchildview] 在父视图中,它不起作用?有什么帮助吗?
HI,
I have Parentview-->Multiple childviews.
when i use [self bringSubviewToFront:childview] in parentview, it works fine.but after adding grandchildview to childview,when i use
[self bringSubviewToFront: grandchildview] in parentview, it did not work?any help please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
-[UIView BringSubviewToFront:]
方法仅适用于直接子级,不适用于孙级。请记住,视图层次结构是一棵树,通常视图只知道其“父视图”(或超级视图)及其直接“子视图”(或子视图)。你需要做这样的事情:The
-[UIView bringSubviewToFront:]
method only works for direct children, not grandchildren. Remember that the view hierarchy is a tree, and normally a view only knows about its "parent" (or superview) and its direct "children" (or subviews). You would need to do something like this:我对已检查解决方案的 swift 版本的贡献
my contribution with the swift version from the checked solution