views:

56

answers:

1

I have an animation in a EAGLView which is itself in a UITableViewCell. How can I pause the animation in the EAGLView when the view is not visible?

Normally, I would simply use the responsible UIViewController and listen to viewDidDisappear. But how do I do that if the EAGLView is in a table?

+1  A: 

I don't think that this is a task to implement at all. Once your cell is scrolled out of view, it will be deallocated instantly. So if you have a Custom Cell, the animation will have to be stopped in -dealloc anyhow.

EDIT 1: Actually, I was not really precise: I wrote "instantly", but of course, this depends on the OS and Apple and may be changed in future versions. Actually, the cell is deallocated whenever the OS garbage collector wants. Currently, Apple deallocates one cell whenever it needs a new one. Usually, scrolling a table implies that one row disappears and a new one appears, so that's why deallocation seems to happen instantly. If the view, that is switched on, contains a table view, than you will see the same instant deallocation.

Jens
Yes, and that works. But how do I detect when another view gets pushed on top of the table? Or if the user goes to another tab?
hanno
Why do you care for some possibly invisible animation? Let it run. A table cell is a UIView and there are not only two states, visible or not visible, but it may be partially visible, an opaque view might be above where the animation shines through and other obscure things. The table cell itself will probably not be able to tell the difference.I usually use -viewWillDisappear: of the controls viewController to stop any unwanted activities.
Jens