确定 UIView 是否对用户可见? [英] Determine if UIView is visible to the user?

查看:25
本文介绍了确定 UIView 是否对用户可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以确定我的 UIView 是否对用户可见?

is it possible to determine whether my UIView is visible to the user or not?

我的视图作为 subview 多次添加到 Tab Bar Controller 中.

My View is added as subview several times into a Tab Bar Controller.

这个视图的每个实例都有一个更新视图的 NSTimer.

Each instance of this view has a NSTimer that updates the view.

但是我不想更新对用户不可见的视图.

However I don't want to update a view which is not visible to the user.

这可能吗?

谢谢

推荐答案

您可以检查:

  • 它是隐藏的,通过检查 view.hidden
  • 它在视图层次结构中,通过检查 view.superview != nil
  • 您可以检查视图的边界以查看它是否在屏幕上

我唯一能想到的另一件事是,如果您的观点被隐藏在其他人之后并且因此无法被看到.您可能需要查看之后出现的所有视图,看看它们是否遮挡了您的视图.

The only other thing I can think of is if your view is buried behind others and can't be seen for that reason. You may have to go through all the views that come after to see if they obscure your view.

这篇关于确定 UIView 是否对用户可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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