【问题标题】:How to remove MPRemoteCommandCenter from Notification Center如何从通知中心删除 MPRemoteCommandCenter
【发布时间】:2019-09-13 06:50:59
【问题描述】:

如何从通知中心删除MPRemoteCommandCenter.shared()。我尝试了这段代码,但只有命令和操作被禁用。我需要从通知中心删除完整通知。当我们杀死应用程序时,它不会出现在通知栏中,我希望在我移动到其他屏幕时执行相同的操作。

func removeCommanCenter() {

let commadCenter = MPRemoteCommandCenter.shared()

    commandCenter.previousTrackCommand.isEnabled = false
    commandCenter.nextTrackCommand.isEnabled = false
    commandCenter.playCommand.isEnabled = false
    commandCenter.pauseCommand.isEnabled = false
    commandCenter.changePlaybackPositionCommand.isEnabled = false

    commandCenter.nextTrackCommand.removeTarget(self, action: #selector(self.loadNextVideos))
    commandCenter.previousTrackCommand.removeTarget(self, action: #selector(self.loadPrevoiusVideos))
    commandCenter.playCommand.removeTarget(self, action: #selector(self.audioPlayerView.customPlayer?.togglePlay(_:)))
    commandCenter.pauseCommand.removeTarget(self, action: #selector(self.audioPlayerView.customPlayer?.togglePlay(_:)))
    commandCenter.changePlaybackPositionCommand.removeTarget(self, action: #selector(self.audioPlayerView.customPlayer?.handleChangePlaybackPositionCommandEvent(event:)))
}

【问题讨论】:

  • 什么是通知栏?
  • @matt,修改了问题——通知中心/锁屏

标签: ios swift avplayer mpremotecommandcenter


【解决方案1】:

如果我们使用endReceivingRemoteControlEvents(),它会从通知中心消失

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多