开发者

Send message from appdelegate to view controller

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 vis开发者_如何学编程ible?

Thank you


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜