Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto rotate to landscape in iOS #773

Closed
3 tasks done
spassvogel opened this issue Sep 4, 2020 · 7 comments
Closed
3 tasks done

Auto rotate to landscape in iOS #773

spassvogel opened this issue Sep 4, 2020 · 7 comments

Comments

@spassvogel
Copy link

spassvogel commented Sep 4, 2020

Bug Report

Problem

What is expected to happen?

on iOS (iPhone) I expect to open an inAppBrowser in portrait mode and have it rotate to landscape mode when the phone rotates

What does actually happen?

The status bar does rotate but the actual inAppBrowser stays fixed in portrait mode

image

Command or Code

this.inAppBrowserRef = cordova.InAppBrowser.open(url, '_blank', 'location=no,hidespinner=yes,toolbar=no');

Environment, Platform, Device

iPhone 5s iOS 12.4.8

Version information

xcode 11.7
cordova-plugin-inappbrowser: 4.0.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Demo project is at: https://github.com/spassvogel/iab-test

@spassvogel spassvogel changed the title Auto rotate in iOS Auto rotate to landscape in iOS Sep 7, 2020
@x-freed
Copy link

x-freed commented Feb 16, 2021

Did you find any solution / workaround for this bug ?

@spassvogel
Copy link
Author

I resorted to using a regular iFrame, unfortunately.

@weiz18
Copy link

weiz18 commented Feb 16, 2021

Hey,

We are having the same issue here as well.
Commenting out line 206 (https://github.com/Yoobic/cordova-plugin-inappbrowser/blob/master/src/ios/CDVWKInAppBrowser.m#L206) seems to resolve the issue, but I'm not sure of the potential side effect this will have. If anyone can help would be nice

@x-freed
Copy link

x-freed commented Feb 16, 2021

@weiz18 thanks, it worked. In the meantime I found also another less robust workaround:
supportedInterfaceOrientations should return directly allowed orientations for the app (https://github.com/Yoobic/cordova-plugin-inappbrowser/blob/master/src/ios/CDVWKInAppBrowser.m#L1263)
In my case: return UIInterfaceOrientationMaskAllButUpsideDown;

@spassvogel
Copy link
Author

Would be nice to get some feedback from the developers of cordova-plugin-inappbrowser on this.

@NielCloete
Copy link

NielCloete commented Jul 16, 2021

For any future lurkers who don't want to fork, I managed to solve this by creating a little Swift extension class in the XCode project.

Add this to the swift file:

import Foundation
import CordovaPlugins

extension CDVWKInAppBrowserViewController {
    override open var shouldAutorotate: Bool {
        return true
    }
    
    override open var supportedInterfaceOrientations : UIInterfaceOrientationMask {
        return .allButUpsideDown
    }
}

@jcesarmobile
Copy link
Member

This isn't a plugin issue but a Capacitor issue, the problem doesn't manifest in Cordova apps.

This PR in Capacitor should fix the issue ionic-team/capacitor#5070

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants