gpt4 book ai didi

ios - MPMoviePlayerController 可以全屏旋转,而应用程序在 ios 7 中仅支持纵向

转载 作者:行者123 更新时间:2023-11-28 22:21:24 25 4
gpt4 key购买 nike

我面临着 same problem这里。但是我的应用程序无法以相同的方式在 iOS 7 上运行。

在视频结束或退出全屏时,应用程序旋转保持横向模式。我手动将设备旋转到纵向位置,然后应用程序变为正常方向位置(纵向)并且不再改变。但在视频结尾的 ios 6 中,设备方向会自动恢复到正常位置。

有人有什么建议吗?

编辑:我现在才意识到。我的应用程序状态栏在视频末尾变为纵向。但是, View 保持横向位置。我尝试反复旋转,然后 View 得到纠正。

最佳答案

在 AppDelegate.h 中:

@property(nonatomic)BOOL allowRotation;

在 AppDelegate.m 中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

RootViewController * root = [[RootViewController alloc] init];
self.window.rootViewController = root;

//add two Notification

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPVisionVideoNotification:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPVisionVideoNotification:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];

self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}

- (void) moviePlayerWillEnterFullscreenNotification:(NSNotification*)notification {
self.allowRotation = YES;
}

- (void) moviePlayerWillExitFullscreenNotification:(NSNotification*)notification {
self.allowRotation = NO;
}

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (self.allowRotation) {

return UIInterfaceOrientationMaskLandscapeRight ;
}
return UIInterfaceOrientationMaskPortrait;
}

//this can rotate the windows when to fullscreen state

关于ios - MPMoviePlayerController 可以全屏旋转,而应用程序在 ios 7 中仅支持纵向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20285356/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com