[_MPWeakInvocationTarget pause]: unrecognized selector sent to instance

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 16:56:04

问题


In PlayerAndLyricsViewController i have added

 class PlayerAndLyricsViewController: UIViewController{

  let commandCenter = MPRemoteCommandCenter.shared()

  override func viewDidLoad() {

         commandCenter.nextTrackCommand.addTarget(self, 
                action:#selector(nextPressed))
         commandCenter.nextTrackCommand.isEnabled = true
    }
   @IBAction func nextPressed(_ sender: Any) {
       // Some code
   }

}

I am using commandCenter to enable and disable for next, back and pause button.

When I initialise PlayerAndLyricsViewController first time Control Center working fine (Next, Pervious, Pause button), then I pop the controller from navigation stack and again initialising this controller from other view controller . Now i am putting application in background and clicking on next button (Control center) or previous button throwing error(Crash)

[_MPWeakInvocationTarget pause]: unrecognized selector sent to instance

or

[_MPWeakInvocationTarget nextPressed]: unrecognized selector sent to instance

I am not getting whats going wrong. Please help me to solve this issue.

来源:https://stackoverflow.com/questions/47711137/mpweakinvocationtarget-pause-unrecognized-selector-sent-to-instance

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!