【发布时间】:2021-11-17 08:23:36
【问题描述】:
我通过SystemVolumeDidChangeNotification never get triggered on iOS 14 询问并找到了解决方案。该事件将被触发,并且可以通过我找到的解决方法在 iOS 14 中观察到。
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIApplication.shared.beginReceivingRemoteControlEvents() // <- THIS LINE
NotificationCenter.default.addObserver(self, selector: #selector(volumeChange(_:)), name: Notification.Name(rawValue: "AVSystemController_SystemVolumeDidChangeNotification"), object: nil)
}
但是,将系统升级到 iOS 15 后,该事件停止触发。
【问题讨论】:
标签: ios swift notificationcenter ios15