带来SubviewToFront问题? [英] bringSubviewToFront problem?

查看:79
本文介绍了带来SubviewToFront问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,
我有Parentview - >多个子视图。
当我在parentview中使用[self bringSubviewToFront:childview]时,它运行正常。但是在将childchildview添加到childview之后,当我在parentview中使用
[self bringSubviewToFront:grandchildview]时,它没有用?任何帮助请?

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?

推荐答案

- [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:

// First, get the view embedding the grandchildview to front.
[self bringSubviewToFront:[grandchildview superview]];
// Now, inside that container view, get the "grandchildview" to front. 
[[grandchildview superview] bringSubviewToFront:grandchildview];

这篇关于带来SubviewToFront问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆