0

我有一个视频列表,我想在用户单击列表项时全屏显示视频播放器,所以我在 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的原因和正确方法,谢谢!

4

1 回答 1

0

I do it myself and it works well for me

[self presentModalViewController:movieController animated:YES];
    // Listen for interesting movie player notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedPlayback:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
于 2012-12-05T02:49:50.827 回答