(iphone) 如何使用 AudioServicesPlaySystemSound 从多个视图播放相同的声音?
我想从各种 UIButton 实例中播放按钮点击声音。
我计划创建一个单例来保存将在许多按钮之间共享的声音文件的“SystemSoundID”。
这行得通吗? (SystemSoundID 在应用程序的生命周期内不会改变?)
还有其他推荐的方法吗?
谢谢
I'd like to play button tap sound from various UIButton instances.
I'm planning to create a singleton to hold "SystemSoundID" of sound files that will be shared across many buttons.
Will this work? (SystemSoundID won't change during app's lifetime?)
Is there a other recommended way of doing this?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您对
UIButton
进行子类化并覆盖其任何触摸事件(如您所愿)并播放声音......通过这种方式,您不必担心每次都播放声音时间,即使您将代码放在“appdelegate”中也会出现这种情况I would suggest you to sub-class
UIButton
and override its any of the touch event (as you want) and play sound.... by this way you don't have to worry about playing sound each time, which will be the case even you put the code in 'appdelegate'