[iOS] how to lock orientation to landscape only in Enterprise build?

I’ve set the “Device Orientation” to “Landscape Left” and “Landscape Right” for both iPhone and iPad in the “General” tab of the app’s settings/deployment info page in XCode 7.  I’ve tried a few other things like overriding shouldAutorotate to false.  No matter what I’ve tried, the app still rotates when put into a portrait orientation!

I’m out of ideas, so I hope someone has an easy fix for this…

Corona staff - is there an equivalent key/value pair that I can use in the info.plist that corresponds to the orientation->content value in the build.settings file?  I haven’t been able to find one yet in my searches.

This is a regression bug from Corona. Try an older version.

I’m not sure if this is relevant but there’s some current discussion of autorotate (for Corona SDK) here: https://forums.coronalabs.com/topic/59359-can-corona-fix-android-orientation-change-bug-fails-to-obey-system-preferences/

Thank you @krystian6.  I went back to the last public release (2015.2646) and the problem did not appear.  I hope this is on their radar to get taken care of soon!

Hello!

To lock Corona orientation in enterprise you would have to edit main plist of your application, adding this array entry:

\<key\>CoronaViewSupportedInterfaceOrientations\</key\> \<array\> &nbsp; &nbsp; \<string\>UIInterfaceOrientationLandscapeLeft\</string\> &nbsp; &nbsp; \<string\>UIInterfaceOrientationLandscapeRight\</string\> \</array\>

Here is more detail:

https://docs.coronalabs.com/daily/native/ios/index.html#orientation

UPDATE: This entry is now being generated from build.settings.

Thanks @vlads!

Hi,

I did what you said Vlads,

it works thanks  :slight_smile:

No more portrait!

But I’ve got only landscapeLeft which works, even if I specified the both (UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight)

Any idea?

Thanks again

Best

Olivier

Hey, [member=‘oromanetti’].

Try syncing with build.settings.

Thanks Vlads

I did it

here my build.settings :

 orientation = { default = "landscapeRight", supported = {"landscapeLeft","landscapeRight"} },

and here a part of my plist :

\<key\>CoronaViewSupportedInterfaceOrientations\</key\> \<array\> \<string\>UIInterfaceOrientationLandscapeLeft\</string\> \<string\>UIInterfaceOrientationLandscapeRight\</string\> \</array\>

only landscapeLeft works…

What does your UISupportedInterfaceOrientations say? Try removing CoronaViewSupportedInterfaceOrientations entry and selecting all orientations in target properties (or UISupportedInterfaceOrientations)

My UISupportedInterfaceOrientations :

\<key\>UISupportedInterfaceOrientations\</key\> \<array\> \<string\>UIInterfaceOrientationLandscapeRight\</string\> \<string\>UIInterfaceOrientationLandscapeLeft\</string\> \</array\>

I’ve got this thing too in my plist

<key>UISupportedInterfaceOrientations~ipad</key>

<array>

<string>UIInterfaceOrientationLandscapeLeft</string>

<string>UIInterfaceOrientationLandscapeRight</string>

</array>

Still doesn’t work? I just downloaded latest version of enterprise, copied example app (deleted everything from it), and just edited build settings. I got app which works in both landscape modes in iOS simulators, bot iPad and iPhone. I can’t reproduce the problem. I don’t have anything related to orientation in plist, or in plist section of build.settings. Only thing I have in build.settings is

[lua]settings =
{
orientation = {
default = “landscapeLeft”,
supported = { “landscapeLeft”, “landscapeRight”},
}
}[/lua]

Here is my project https://dl.dropboxusercontent.com/u/2658771/landscapeOrientationTest.zip (it will unpack in folder App)

@oromanetti:

make sure your build target is using the plist file you make changes in.

I use several targets and sometimes forget to change all of the plist files.

Just a thought, since your settings look correct.

Thanks Vlads, thanks Kristian,

@Kristian : I checked, my build target is using the plist file I make changes in.

@Vlads : I downloaded your project thanks.

But how do you know that it works for both landscapes as there is no objects on the screen?

I created a newText object to verify, and it doesn’t work for me.

The newText object doesn’t follow the orientation. Even worse, newText is written as if we were on a portrait mode :frowning:

See below a screenshot

here the new main.lua

local r = display.newRect( display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight ) r.stroke = {1,0,0} r.strokeWidth = 20 local options = { text = "Test Test Test", fontSize = 60, align = "center" --new alignment parameter } local label = display.newText(options) label:setFillColor(0) label.x = display.contentCenterX label.y = display.contentCenterY

@oromanetti

just to make sure: are you using the latest corona?

Sorry for dump questions, but sometimes when issue becomes so weird, it’s the simplest things that we forget about [well I do!].

This is a regression bug from Corona. Try an older version.

I’m not sure if this is relevant but there’s some current discussion of autorotate (for Corona SDK) here: https://forums.coronalabs.com/topic/59359-can-corona-fix-android-orientation-change-bug-fails-to-obey-system-preferences/

Thank you @krystian6.  I went back to the last public release (2015.2646) and the problem did not appear.  I hope this is on their radar to get taken care of soon!

Hello!

To lock Corona orientation in enterprise you would have to edit main plist of your application, adding this array entry:

\<key\>CoronaViewSupportedInterfaceOrientations\</key\> \<array\> &nbsp; &nbsp; \<string\>UIInterfaceOrientationLandscapeLeft\</string\> &nbsp; &nbsp; \<string\>UIInterfaceOrientationLandscapeRight\</string\> \</array\>

Here is more detail:

https://docs.coronalabs.com/daily/native/ios/index.html#orientation

UPDATE: This entry is now being generated from build.settings.

Thanks @vlads!