它是一個已知的問題,您正在使用ARC該ID,那麼你必須給玩家添加到您的.h因爲,如果你在本地聲明它仍然得到釋放。
@property (nonatomic, strong) MPMoviePlayerController* controller;
要添加視圖:
self.controller = [[MPMoviePlayerController alloc] initWithContentURL:YOURVIDEOURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.controller];
self.controller.controlStyle = MPMovieControlStyleDefault;
self.controller.shouldAutoplay = YES;
[self.view addSubview:self.controller.view];
[self.controller setFullscreen:YES animated:YES];
然後刪除視圖:
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];
}
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
請張貼有關加入moviePlayer試了試視圖 –