views:

356

answers:

1

Hey,

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

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

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

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

Is this possible?

Thanks

+1  A: 

You can check if:

  • it is hidden, by checking view.hidden
  • it is in the view hierarchy, by checking view.superview == nil
  • you can check the bounds of a view to see if it is on screen

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.

mahboudz
I did that this way but forgot to post the solution here :) Thanks (+1)
Ghommey