system.orientation returns wrong value on startup

I use the portrait mode in my app and rotate and adapt the content manually within a orientationChange listener. That works great, but there is a big issue. If I try to get the current orientation on startup with system.orientation, i get always “portrait” as the return value, whatever orientation the device currently has.

How can I get the correct orientation immediately after startup?

Thanks!

I think I should go in more detail, to make my problem a bit more clear. My App supports both, iPad and iPhone. Build.settings look like this:

orientation = { default = "portrait", supported = { "portrait"} },

I dont want to use the auto rotation feature of corona, because I have to scale and reposition the content, what looks much smoother with my own transition, also I don’t allow rotation at any time what also excludes autoRotation for me. All works perfect so far, but it seems that there is no way to determine in what orientation the app has started if the orientation differs from the supported orientations in build.setting. There are two solutions in my mind:

  1. I could support all orientations in build.settings if there is a way to avoid the auto rotation. Instead I do the rotation manually within     an orientation or resize event if needed.

  2.   I find a way to get the correct orientation on startup.  So it would be useful to know if this is a known issue with will be fixed soon or if there exists a workaround. Or should I report a bug?

Thanks!

Mike

The orientation returned is what the OS gives Corona and we have found that depends on the device and the version of OS. We don’t have any control over that and can’t ensure  that it’s behavior won’t change in the next version of the OS.

If you are only creating iOS apps, you can add “content” to the build.settings file. The intent is to not allow auto-rotation. It was added a long time ago and not sure how useful it is now.

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

content = “portrait”, – Locked orientation of the Corona stage, independent of Native UI elements (iOS only)

Thanks for your reply Tom.

I tried what you have suggested, and this seems to be a possible solution. But unfortunately the content is still rotated by corona, although I set the content to portrait. It works on the simulator, but not an my iPad3 with current iOS. The strange thing is, the content will be rotated AND stretched to fit the screen, so everything is disorted. It is a different behavior then the normal autoRotation, which is just the rotation without any changes to the x/y scale.

Any ideas? 

My build.settings now:

 orientation = { default = "portrait", content = "portrait", supported = { "portrait", "portraitUpsideDown", "landscapeLeft", "landscapeRight"} },

Sorry, but can anybody confirm, that, if I set the build settings like in my last post, the stage should not be rotated on orientation changes? That would mean, that there is a bug.

I tried different devices and iOS Versions, and always the same. The stage will be rotated and stretched to fit the screen. That really drives me crazy  :wacko: .

Thnaks!

If have reported a bug now (Case 42139). It would be awesome if somebody could look into it shortly. App release is very probably by end of this month and it would be great if I could manage that before.

Thanks!  :slight_smile:

with regards from germany,

Mike

I think I should go in more detail, to make my problem a bit more clear. My App supports both, iPad and iPhone. Build.settings look like this:

orientation = { default = "portrait", supported = { "portrait"} },

I dont want to use the auto rotation feature of corona, because I have to scale and reposition the content, what looks much smoother with my own transition, also I don’t allow rotation at any time what also excludes autoRotation for me. All works perfect so far, but it seems that there is no way to determine in what orientation the app has started if the orientation differs from the supported orientations in build.setting. There are two solutions in my mind:

  1. I could support all orientations in build.settings if there is a way to avoid the auto rotation. Instead I do the rotation manually within     an orientation or resize event if needed.

  2.   I find a way to get the correct orientation on startup.  So it would be useful to know if this is a known issue with will be fixed soon or if there exists a workaround. Or should I report a bug?

Thanks!

Mike

The orientation returned is what the OS gives Corona and we have found that depends on the device and the version of OS. We don’t have any control over that and can’t ensure  that it’s behavior won’t change in the next version of the OS.

If you are only creating iOS apps, you can add “content” to the build.settings file. The intent is to not allow auto-rotation. It was added a long time ago and not sure how useful it is now.

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

content = “portrait”, – Locked orientation of the Corona stage, independent of Native UI elements (iOS only)

Thanks for your reply Tom.

I tried what you have suggested, and this seems to be a possible solution. But unfortunately the content is still rotated by corona, although I set the content to portrait. It works on the simulator, but not an my iPad3 with current iOS. The strange thing is, the content will be rotated AND stretched to fit the screen, so everything is disorted. It is a different behavior then the normal autoRotation, which is just the rotation without any changes to the x/y scale.

Any ideas? 

My build.settings now:

 orientation = { default = "portrait", content = "portrait", supported = { "portrait", "portraitUpsideDown", "landscapeLeft", "landscapeRight"} },

Sorry, but can anybody confirm, that, if I set the build settings like in my last post, the stage should not be rotated on orientation changes? That would mean, that there is a bug.

I tried different devices and iOS Versions, and always the same. The stage will be rotated and stretched to fit the screen. That really drives me crazy  :wacko: .

Thnaks!

If have reported a bug now (Case 42139). It would be awesome if somebody could look into it shortly. App release is very probably by end of this month and it would be great if I could manage that before.

Thanks!  :slight_smile:

with regards from germany,

Mike