App Orientation Issue

Hi,

I’m trying to set my app to support three orientation (portrait and landscapes), however I want the Corona stage to always stay in the same (portrait) orientation, while the native elements (like the keyboard) rotate according to the orientation of the device.

From the docs  it looks that to achieve that I need to add in the build settings something like this:

settings = {     orientation =     {         default = "portrait",  -- Initial launch orientation         content = "portrait",  -- Locked orientation of the Corona stage, independent of native UI elements (iOS only)         supported = {"portrait","landscapeLeft","landscapeRight"},  -- Table of allowed options for auto-orientation     }, }

In this way the orientation of the Corona stage should be fixed to portrait while the native UI rotates. The docs also state:

In iOS, you can optionally use the content key value to lock the Corona stage to a particular orientation. Native UI elements such as alerts or the visual keyboard will auto-orient, but the Corona display stage will remain locked. This is useful if you want to maintain a fixed coordinate system in an iOS app.

 

However, when I try on device the “content” parameter doesn’t seem to do anything… the Corona view is not locked to the portrait position but auto-rotates.

 

Am I doing something wrong? Or is that function broken? 

Thanks

 

Note: I’m developing for iOS by the way, not Android.

Your “supported” table tells the app orientations to which it can rotate. If you remove that, it should stay at the “default” value.

EDIT: Gah, I need to do a better job of reading issues before commenting so I can explain my thoughts more clearly.

From reading the docs, I would say that the auto-orientation would be performed by iOS instead of by your Corona-developed app, so leaving out the “supported” table should do the trick.

Hi Alex, yes I know that, the issue is different though.

The " supported" table set the supported orientation of my apps, however the " content" setting should restrict the Corona view to a single orientation.  

It’s also stated in the docs:

you can optionally use the  content  key value to lock the Corona stage to a particular orientation. Native UI elements such as alerts or the visual keyboard will auto-orient, but the Corona display stage will remain locked

Basically what I’m trying to do is:

  1. make the Corona view stay always locked in the same portrait position (portrait)

  2. make the native elements (keyboard view, etc etc) rotate to landscape left and landscape right

  3. then adjust some UI elements of the corona view when rotated using a simple orientation listener

It seems that the settings.orientation.content  should do 1. & 2. , however on device it doesn’t lock the corona view as specified but rotate and stretch it. 

Alex, unfortunately no… Without “supported” everything is locked to the portrait position :frowning:

Ok, searching on the forum, it looks like this is a bug and has already been reported in august 2015.

Here’s the post: https://forums.coronalabs.com/topic/58333-systemorientation-returns-wrong-value-on-startup/?p=302215

The bug case is:  42139

Any way to check the bug report?

BTW, the “content” setting works in the simulator (native elements auto-rotate, corona view is locked), but NOT on device.

Gotcha. Again, my bad for misunderstanding and posting incorrect info.

Anyone from Corona?

Anyone can tell me what has been on the bug case  42139 ?****?

Hi @PXL artificer,

I asked for a quick update on this bug case from the engineers. It seems that the feature you’re talking about was added a long time ago, in the early days of Corona/iOS (iOS 3.x or so) and it may have various issues now. We may actually deprecate this entirely, since it doesn’t work on Android and thus doesn’t serve much of a cross-platform purpose.

A better approach would probably be to support multiple orientations but then rotate your Corona stage objects using an “orientation” listener so that it remains in the “locked” orientation you want.

Best regards,

Brent

Hi Brent, thanks for taking the time to check the report.

I was doing some tests and generally you could use the “orientation” listener and even directly rotate and adjust the position of the display.getCurrentStage() object.

Unfortunately there are issues still remaining, like the native rotation animation  when you support multiple rotation (it’s not really pretty). Also, in my app I have a camera texture feed, and it’s quite glitchy with changes of ratio/rotation. I guess I’ll just remove support of the multiple orientation for now.

At this point, it would be probably better to remove the line about the content value in the configuration file.

It works correctly only on Simulator. On device instead it rotate the Corona view and also switch width/height (so basically the corona view is rotated instead of being locked, and it’s also stretched to the dimensions  of the new orientation)

Your “supported” table tells the app orientations to which it can rotate. If you remove that, it should stay at the “default” value.

EDIT: Gah, I need to do a better job of reading issues before commenting so I can explain my thoughts more clearly.

From reading the docs, I would say that the auto-orientation would be performed by iOS instead of by your Corona-developed app, so leaving out the “supported” table should do the trick.

Hi Alex, yes I know that, the issue is different though.

The " supported" table set the supported orientation of my apps, however the " content" setting should restrict the Corona view to a single orientation.  

It’s also stated in the docs:

you can optionally use the  content  key value to lock the Corona stage to a particular orientation. Native UI elements such as alerts or the visual keyboard will auto-orient, but the Corona display stage will remain locked

Basically what I’m trying to do is:

  1. make the Corona view stay always locked in the same portrait position (portrait)

  2. make the native elements (keyboard view, etc etc) rotate to landscape left and landscape right

  3. then adjust some UI elements of the corona view when rotated using a simple orientation listener

It seems that the settings.orientation.content  should do 1. & 2. , however on device it doesn’t lock the corona view as specified but rotate and stretch it. 

Alex, unfortunately no… Without “supported” everything is locked to the portrait position :frowning:

Ok, searching on the forum, it looks like this is a bug and has already been reported in august 2015.

Here’s the post: https://forums.coronalabs.com/topic/58333-systemorientation-returns-wrong-value-on-startup/?p=302215

The bug case is:  42139

Any way to check the bug report?

BTW, the “content” setting works in the simulator (native elements auto-rotate, corona view is locked), but NOT on device.

Gotcha. Again, my bad for misunderstanding and posting incorrect info.

Anyone from Corona?

Anyone can tell me what has been on the bug case  42139 ?****?

Hi @PXL artificer,

I asked for a quick update on this bug case from the engineers. It seems that the feature you’re talking about was added a long time ago, in the early days of Corona/iOS (iOS 3.x or so) and it may have various issues now. We may actually deprecate this entirely, since it doesn’t work on Android and thus doesn’t serve much of a cross-platform purpose.

A better approach would probably be to support multiple orientations but then rotate your Corona stage objects using an “orientation” listener so that it remains in the “locked” orientation you want.

Best regards,

Brent

Hi Brent, thanks for taking the time to check the report.

I was doing some tests and generally you could use the “orientation” listener and even directly rotate and adjust the position of the display.getCurrentStage() object.

Unfortunately there are issues still remaining, like the native rotation animation  when you support multiple rotation (it’s not really pretty). Also, in my app I have a camera texture feed, and it’s quite glitchy with changes of ratio/rotation. I guess I’ll just remove support of the multiple orientation for now.

At this point, it would be probably better to remove the line about the content value in the configuration file.

It works correctly only on Simulator. On device instead it rotate the Corona view and also switch width/height (so basically the corona view is rotated instead of being locked, and it’s also stretched to the dimensions  of the new orientation)