-[MPTransportButton _isChargeEnabled]: message sen

2019-08-20 18:22发布

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

3条回答
Rolldiameter
2楼-- · 2019-08-20 18:44

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.

查看更多
劫难
3楼-- · 2019-08-20 18:59

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!

查看更多
欢心
4楼-- · 2019-08-20 19:02

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.

查看更多
登录 后发表回答