-[MPTransportButton _isChargeEnabled]: message sen

2019-08-20 18:04发布

问题:

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.