在名为《Swift 应用程序开发》的 iBook 中,有一章介绍创建“动物声音”的应用程序
iBook 附带 downloadable source
请参阅 zip 文件中 iBook 中的第 18 课和 18_adaptiveUserInterfaces 文件夹。
第 1 步:按照 iBook 类(class)“动物声音”部分中的说明创建应用程序。
第 2 步:运行项目
第 3 步。单击动物按钮。没有声音
第 4 步。现在在 SimpleSound.swift 文件、play() 函数中添加断点。
第 5 步。再次单击 aminal 按钮,将命中断点。
第 6 步。跨过几次,就会听到声音。
没有断点怎么能听到这个声音?
最佳答案
添加延迟后,它起作用了,如下所示:
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(5), execute: {AudioServicesPlaySystemsound(soundId)})
AudioServicesPlaySystemsound(soundId)
}
关于ios - 在 Swift 3 和 XCODE 8.2 中,声音仅在命中断点时播放。如何解决,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41178180/