【发布时间】:2015-02-11 22:16:54
【问题描述】:
我有一个带有视频链接的 web 视图,该应用程序只有纵向,但当视频全屏并使用全屏时,我需要更改方向。 感谢您的帮助。
【问题讨论】:
标签: ios objective-c uiwebview orientation
我有一个带有视频链接的 web 视图,该应用程序只有纵向,但当视频全屏并使用全屏时,我需要更改方向。 感谢您的帮助。
【问题讨论】:
标签: ios objective-c uiwebview orientation
把这个放在你的AppDelegate:
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
id presentedViewController = [window.rootViewController presentedViewController];
NSString *className = presentedViewController ? NSStringFromClass([presentedViewController class]) : nil;
if (window && [className isEqualToString:@"AVFullScreenViewController"]) {
return UIInterfaceOrientationMaskAll;
} else {
return UIInterfaceOrientationMaskPortrait;
}
}
注意:我没有在 iOS7 上对此进行了测试,但在 iOS8 上运行良好
【讨论】:
UIInterfaceOrientationMask,而不是 NSUInteger
除了this answer 用于 iOS 7 和 iOS 8
放入 AppDelegate。适用于 iOS 7 和 iOS 8:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
id presentedViewController = [window.rootViewController presentedViewController];
NSString *className = presentedViewController ? NSStringFromClass([presentedViewController class]) : nil;
if (window && ([className isEqualToString:@"MPInlineVideoFullscreenViewController"] || [className isEqualToString:@"AVFullScreenViewController"])) {
return UIInterfaceOrientationMaskAll;
} else {
return UIInterfaceOrientationMaskPortrait;
}
}
【讨论】: