我有一个视频列表,我想在用户单击列表项时全屏显示视频播放器,所以我在 didSelectRowAtIndexPath 方法中添加了代码:
[[[UIApplication sharedApplication].delegate window] addSubview:vc.view];
在视频控制器中,我在视图 didload 中添加 NSNotificationCenter 代码并添加操作代码
[[NSNotificationCenter defaultCenter] addObserver:moviePlayer
selector:@selector(doneButtonClick:) name:MPMoviePlayerDidExitFullscreenNotification
object:nil];
-(void)doneButtonClick:(NSNotification *)Notification{
NSLog(@"...............doneButtonClick....... \n ");
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerDidExitFullscreenNotification object:nil];
[moviePlayer stop];
[self.view removeFromSuperview];
}
当我点击完成按钮时,它不能工作,但如果我改变
[[[UIApplication sharedApplication].delegate window] addSubview:vc.view];
至
[[[UIApplication sharedApplication].delegate window] setRootViewController:vc];
完成按钮可以正常工作,谁能告诉我在全屏窗口中添加MPMovieController的原因和正确方法,谢谢!