iphone sdk出现alertview时如何播放声音?
我想在 Alertview 出现时播放声音文件并持续播放,直到用户单击“确定”或“取消”。我该如何执行此操作?
i want to play a sound file when alertview appears and plays continuously till user clicks on ok or cancel.how do i do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 Zoul 所说,您在调用 [myAlert show] 时设置并播放声音,并在警报视图回调中取消声音。您的代码将如下所示:
As Zoul says, you set-up and play your sound as you call [myAlert show] and cancel the sound in the alert view callback. Your code will look something like this:
由于您已经调用
show
方法来显示对话框,为什么不直接开始播放声音并在 警报视图回调?对于声音本身,您可以使用AVAudioPlayer
。As you already call the
show
method to display the dialog, why don’t you simply start playing the sound there and stop in the alert view callback? For the sound itself you can useAVAudioPlayer
.