ios - Swift 3 中的 AVAudiosessionInterruptionNotification

标签 ios swift xcode swift3 swift2

这是我在 swift 2 中的代码。

如何在 swift 3 中使用同样的东西?

NotificationCenter.default.addObserver(self, selector: "handleInterruption", name: AVAudiosessionInterruptionNotification, object: nil)

提前致谢!

最佳答案

看看this fine answer

正如它所说:

All of the system notification types are now defined as static constants on Notification.Name; i.e. .UIApplicationDidFinishLaunching, .UITextFieldTextDidChange, etc.

因此,在您的情况下,您可能正在寻找 Notification.Name.AVAudioSessionInterruption

我认为这对你有用:

NotificationCenter.default.addObserver(self, selector: #selector(handleInterruption), name: .AVAudioSessionInterruption, object: nil)

希望对您有所帮助。

关于ios - Swift 3 中的 AVAudiosessionInterruptionNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42626032/

相关文章:

ios - 在 View 中创建、拖动和选择一些图标

ios - LLDB 手册/文档

ios - 如何在 iOS 中使用预设的 cookie 或 header 在 Safari 中打开 URL?

ios - 无法在 Xcode 11 的 Storyboard 中设置 UIView 的比例高度

ios - InstagramKit 收到的ValidAccessTokenFromURL 不起作用

ios - swift 3 : URL Image makes UITableView scroll slow issue

ios - 如何使容器 View 背景透明而不是一切?

objective-c - 如何去检测 dismissModalViewControllerAnimated

ios - 使 iOS 应用程序在启动时运行

ios - 使用RxSwift Observables进行递归调用