-[MPTransportButton _isChargeEnabled]: message sent to deallocated instance 0x4bf6cb0

拈花ヽ惹草 提交于 2019-12-12 04:43:42

问题


I'm using the MPMoviePlayerViewController to play a video. The videoplayer will shown as presentModalViewController. If the video is finished and the view is dismissed. I get the error :

 -[MPTransportButton _isChargeEnabled]: message sent to deallocated instance 0x4bf6cb0

But I have no idea, where the error comes.

Thanks in advance.

Greeting,

Patrick


回答1:


The message says: object of class MPTransportButton whose value was stored at 0x4bf6cb0 has been released and then used again.

So, you need to find object of type MPTransportButton that was released and then reused.




回答2:


You may be trying to dismiss the video player several times when removing the modal?

Make sure your un-register from all notifications before dismissing the player view too (MPMoviePlayerLoadStateDidChangeNotification, MPMoviePlayerPlaybackStateDidChangeNotification, ...)

- (void)closeVideoPlayer
{
       [[NSNotificationCenter defaultCenter] removeObserver:self];  

       if (mp)
       {                
            [mp stop];
            [mp.view removeFromSuperview];
            mp = nil;       

            [self dismissModalViewControllerAnimated:animated];
        }
}

Good luck!




回答3:


Related to jotaefe's answer: check to make sure that your MPMoviePlayerController's view isn't still in the hierarchy after the MPMoviePlayerController has been released. This situation could leave dangling references to some of your MPMoviePlayerController's views subviews which in turn could yield your zombie "message sent to deallocated instance" error.



来源:https://stackoverflow.com/questions/7644930/mptransportbutton-ischargeenabled-message-sent-to-deallocated-instance-0x4b

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