can you rotate a webview \ or cahnge orientation settings support in the middle of an app ?

i’m having a problem in my app where i need to open a webview horizontally, (and all the content inside of it)

but my app is written on portrait, 

so can i change the webview that although the app is written as portrait to open the stuff INSIDE of it horizontally ? or rotate the actual web view ?

or on the other hand, 

can i in the middle of an app life spen (let’s say when i move to a new screen)

lock screen orientation to horizontal only (meaning the app will only be horizontal and not portrait)

and on another screen lock the screen orientation to portrait only ?

Hi @Mars Interactive,

You can definitely rotate web views, however you can’t “lock” the orientation to one or the other axes mid-run.

Take care,

Brent

how can you rotate a web view ? i tried 

webView.rotate = 90

and i tried

webView:rotate (90)

none worked 

how do you rotate them ?

Try “.rotation” (there is no such thing as “.rotate”).

ye i managed to fix it didn’t had enough time to reply… thnx !

ok corona so is there a way to support Portrait only, but to rotate the Content INSIDE a web view to horizontal ?

Hi @Mars Interactive,

I can’t vouch for the behavior since I haven’t tested it in a long while, but consider adding a “content” table to the “orientation” table in “build.settings”, placing only the portrait-related strings in there. Then in the “supported” table, add all four standard strings.

https://docs.coronalabs.com/guide/distribution/buildSettings/index.html#orientation

As noted, if this works, it would be for iOS only. Please report back your findings. :slight_smile:

Brent

Hi @Mars Interactive,

You can definitely rotate web views, however you can’t “lock” the orientation to one or the other axes mid-run.

Take care,

Brent

how can you rotate a web view ? i tried 

webView.rotate = 90

and i tried

webView:rotate (90)

none worked 

how do you rotate them ?

Try “.rotation” (there is no such thing as “.rotate”).

ye i managed to fix it didn’t had enough time to reply… thnx !

ok corona so is there a way to support Portrait only, but to rotate the Content INSIDE a web view to horizontal ?

Hi @Mars Interactive,

I can’t vouch for the behavior since I haven’t tested it in a long while, but consider adding a “content” table to the “orientation” table in “build.settings”, placing only the portrait-related strings in there. Then in the “supported” table, add all four standard strings.

https://docs.coronalabs.com/guide/distribution/buildSettings/index.html#orientation

As noted, if this works, it would be for iOS only. Please report back your findings. :slight_smile:

Brent

Hello there,

So, I’m working with @Mars Interactive on this, and here’s our issue:

We have an app that we released a couple of years ago, and we wanted to add a feature to it.

The feature is a Web-Based game that can be played on a webview.

The app is locked to Portrait, and the game displays best on Landscape.

The webview, AND it’s content, rotates perfectly fine on iOS, using webview:rotate(90). 

But, on Android, it just changes the width and height while the content stays as Portrait.

 Any suggestion will help,

thank you…

Hi @mor.maslati,

As stated in the documention (see Gotchas > Android), native web views cannot be rotated on Android. This is an OS limitation.

https://docs.coronalabs.com/api/library/native/newWebView.html

You may be able to use the older “showWebPopup()” API, but I don’t recall how this behaves on Android when a portrait-locked app is rotated to landscape. Unfortunately, I suspect it will just continue showing the web content in portrait view.

https://docs.coronalabs.com/api/library/native/showWebPopup.html

Other than that, you might have to allow the app to rotate to landscape naturally (support both portrait and landscape), and then handle any UI repositioning factors in the resize/orientation event listener.

Best regards,

Brent

Hello there,

So, I’m working with @Mars Interactive on this, and here’s our issue:

We have an app that we released a couple of years ago, and we wanted to add a feature to it.

The feature is a Web-Based game that can be played on a webview.

The app is locked to Portrait, and the game displays best on Landscape.

The webview, AND it’s content, rotates perfectly fine on iOS, using webview:rotate(90). 

But, on Android, it just changes the width and height while the content stays as Portrait.

 Any suggestion will help,

thank you…

Hi @mor.maslati,

As stated in the documention (see Gotchas > Android), native web views cannot be rotated on Android. This is an OS limitation.

https://docs.coronalabs.com/api/library/native/newWebView.html

You may be able to use the older “showWebPopup()” API, but I don’t recall how this behaves on Android when a portrait-locked app is rotated to landscape. Unfortunately, I suspect it will just continue showing the web content in portrait view.

https://docs.coronalabs.com/api/library/native/showWebPopup.html

Other than that, you might have to allow the app to rotate to landscape naturally (support both portrait and landscape), and then handle any UI repositioning factors in the resize/orientation event listener.

Best regards,

Brent