我可能没有写出我的标题很好,也许更正确的说,我的NSNotification不会在播放后解散我的电影的观点.我发现其他人有这个问题,但没有解决方案,似乎这可能是iOS 6的问题,这是我正在运行.
播放视频后,您需要按“完成”才能关闭,但是我希望自动关闭,因为一旦我将其整理出来,我将使用MPMovieControlStyleNone.这是我的代码与未使用的部分被剥离:
`
#import "MovieViewController.h" @interface MovieViewController () @end @implementation MovieViewController @synthesize moviePlayer = _moviePlayer; - (IBAction)playMovie:(id)sender { NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"TestMovie" ofType:@"mov"]]; _moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:_moviePlayer]; _moviePlayer.controlStyle = MPMovieControlStyleDefault; _moviePlayer.shouldAutoplay = YES; [self.view addSubview:_moviePlayer.view]; [_moviePlayer setFullscreen:YES animated:NO]; } - (void) moviePlayBackDidFinish:(NSNotification*)notification { MPMoviePlayerController *player = [notification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player]; if ([player respondsToSelector:@selector(setFullscreen:animated:)]) { [player.view removeFromSuperview]; } } @end`