應項目要求沮趣,播放器要實現全屏之后橫屏,查找半天資料終于找到相應的資料
資料源:http://www.reibang.com/p/deecfa886dac
實現方法:
在appdelegate頁面:
.h
@property(nonatomic)BOOL allowRotation;
.m
pragma mark ------------ MediaPlayer選擇全屏模式
實現以下方法
- (void)addMoviePlaybackRotateNotification{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillEnterFullscreenNotification:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillExitFullscreenNotification:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
} - (void) moviePlayerWillEnterFullscreenNotification:(NSNotification*)notification {
self.allowRotation = YES;
} - (void) moviePlayerWillExitFullscreenNotification:(NSNotification*)notification {
self.allowRotation = NO;
}
-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (self.allowRotation) {
項目要求直接橫屏,所以我只選擇一個方向敌蚜。
return UIInterfaceOrientationMaskLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}
現在就可以實現全屏啦