我想强制视频全屏只在风景上,我试过这个。但它不起作用。应用程序的其余部分只有肖像。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillEnterFullscreenNotification:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillExitFullscreenNotification:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
Second, Add the method and property
- (void) moviePlayerWillEnterFullscreenNotification:(NSNotification*)notification {
self.allowRotation = YES;
}
- (void) moviePlayerWillExitFullscreenNotification:(NSNotification*)notification {
self.allowRotation = NO;
}
Third, override the supportedInterfaceOrientationsForWindow method, you can return whatever orientation you want
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (self.allowRotation) {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}
答案 0 :(得分:0)
您必须导入<MediaPlayer/MediaPlayer.h>
并添加属性allowRotation
和方法-(void)moviePlayerWillEnterFullscreenNotification:(NSNotification*)notification
和
AppDelegate.h中的-(void)moviePlayerWillExitFullscreenNotification:(NSNotification*)notification
。