开发者

How can I add a startup sound when UIViewController *controller is initiated?

ViewDidLoad doesnt work. ViewDidappear Doesnt work.

No matter what happens, the sound is played then the viewController image is开发者_运维技巧 displayed.

What I want is the image to be displayed, then the sound plays simultaneously'


did you try viewWillAppear?


That could be because things happen in SEQUENCE unless you give explicit instructions that you want things to happen at the same time. If you want a sound to play WHILE an image is loading you need to use threads.

This guide explains how to accomplish that


I think viewWillAppear might work. viewDidLoad only gets called once, so it wouldn't get played every time a view controller is pushed.


I ended up making the sound effect have an extra 1 second pause at the beginning of it and playing it in viewdidappear. Not the perfect solution, but it was the easiest.

The sound was originally being played, before the phone actually rendered the viewcontroller, which I found counter intuitive seeing as the method 'viewdidappear' kinda sounds like the view should have erm already appeared.

Does that make sense?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜