Ghostnars Ghostnars - 1 year ago 150
iOS Question

how can i set landscape orientation when playing a video from webview

i have a webview with a video link, the app is only portrait orientation but i need to change orientation when the video is in fullscreen and use all screen.
Thanks for your help.

Answer Source

Put this in your 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;

Note: I have not tested this with iOS7 but works well with iOS8

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download