如何在从webview播放视频时设置横向方向

Gho*_*ars 3 objective-c uiwebview orientation ios

我有一个带有视频链接的webview,该应用程序只是纵向,但我需要在视频全屏时更改方向并使用所有屏幕.谢谢你的帮助.

sou*_*ned 11

把它放在你的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;
    }
}
Run Code Online (Sandbox Code Playgroud)

注意:我没有使用iOS7 对此进行测试,但适用于iOS8