Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

system.orientation returns wrong value on startup
Started by sunmils Aug 03 2015 12:34 AM

5 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

sunmils

[GLOBAL: userInfoPane.html]
sunmils
  • Contributor

  • 197 posts
  • Corona SDK

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!



[TOPIC: post.html]
#2

sunmils

[GLOBAL: userInfoPane.html]
sunmils
  • Contributor

  • 197 posts
  • Corona SDK

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



[TOPIC: post.html]
#3

Tom

[GLOBAL: userInfoPane.html]
Tom
  • Moderator

  • 1,480 posts
  • Corona Staff

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)



[TOPIC: post.html]
#4

sunmils

[GLOBAL: userInfoPane.html]
sunmils
  • Contributor

  • 197 posts
  • Corona SDK

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"}
            
        },


[TOPIC: post.html]
#5

sunmils

[GLOBAL: userInfoPane.html]
sunmils
  • Contributor

  • 197 posts
  • Corona SDK

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!



[TOPIC: post.html]
#6

sunmils

[GLOBAL: userInfoPane.html]
sunmils
  • Contributor

  • 197 posts
  • Corona SDK

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!  :)

 

with regards from germany,

Mike




[topic_controls]
[/topic_controls]