我的应用程序必须在 iOS5 和更高版本中运行。我正在将 MPMoviePlayerViewController 添加到 mainWindow 单击按钮时。moviePlayerController 的完成按钮不会从窗口中删除moviePlayerController。
我的代码是
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"001 ATSW" ofType:@"m4v"]];
self.player = [[MPMoviePlayerViewController alloc]
initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[self.player.view setFrame:[UIScreen mainScreen].bounds];
[[[UIApplication sharedApplication] keyWindow] addSubview:self.player.view];
[[self.player moviePlayer] play];
}
-(void)videoPlayBackDidFinish:(NSNotification*)notification {
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[self.player.moviePlayer stop];
self.player = nil;
[self.player.view removeFromSuperview];
}
如何在单击完成按钮时删除moviePlayerController。
请提供任何帮助。