views:

17

answers:

1

Hello,

I have a view (nib) loading offscreen in a uiscrollview. I want the movie in this view to only start playing once it is visible but the viewdidappear fires even the view is off screen. So the movie is playing even though you can't see it.

Is there a way to understand what view is actually visible that does not involve the uiscrollview (built within the app delegate)? Or if I use the appdel uiscrollview to understand the page, can I send a message to the viewcontroller when it is visible?

Thank you

+2  A: 

You need to set something at the UIScrollView's delegate, and implement scrollViewDidScroll:

inside scrollViewDidScroll you should check what the view.contentOffset.x and view.contentOffset.y are, and if they correspond to the movie being onscreen, and the movie isn't playing, send it a message to play. If the movie is playing and is offscreen, send it a message to pause.

Alex Gosselin
I see. I did end up getting this to work using nsnotification but I only would have been able to do this with your tip of sending it a message. Post a notif in the appdel and add a listener in the view controller. Works perfectly.
malaki1974