ビデオリストがあり、ユーザーがリストアイテムをクリックしたときにビデオプレーヤーを全画面で表示したいので、didSelectRowAtIndexPathmoethodにコードを追加します。
[[[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を全画面表示のウィンドウに追加する理由と正しい方法を教えてくれます。ありがとうございます。