这是我在 swift 2 中的代码。
如何在 swift 3 中使用同样的东西?
NotificationCenter.default.addObserver(self, selector: "handleInterruption", name: AVAudiosessionInterruptionNotification, object: nil)
提前致谢!
最佳答案
正如它所说:
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/