iOS 6 Orientation Crash

I also experienced the same type of crash, not with Game Center, but by opening the device’s photo library using media.show( media.PhotoLibrary, sessionComplete) on a landscape-only restricted app. The fix noted above also fixes this crash.
[import]uid: 9422 topic_id: 31056 reply_id: 124818[/import]

I had to modify the fix slightly to get my app to work in both landscape orientations. The original fix displays native objects correctly but all corona display objects are upside-down in one of the landscape orientations. Here’s the revised fix:

[code]
orientation =
{
default = “landscapeRight”,
content = {“landscapeRight”,“landscapeLeft”},
supported =
{
“landscapeRight”,“landscapeLeft”, “portrait”,
},

},
[/code] [import]uid: 9422 topic_id: 31056 reply_id: 124990[/import]

Blarg… maybe I spoke too soon. Following the advice here it seems that my Corona apps go into portrait orientation when I rotate the device (or simulator) left 90 degrees (curiously, rotation right works as expected).

Has anyone successfully worked around this issue - i.e. - iOS 6, landscape only orientations, native ui (game center, photo library, text boxes) not crashing, rotate left not causing screen orientation to change to portrait?

[import]uid: 9422 topic_id: 31056 reply_id: 125001[/import]

It’s certainly not the prettiest or efficient bit of code - and I haven’t tested it extensively, but this should help anybody who’s struggling with the lack of print statements on device in xCode following iOS6/xCode 4.5.

Simply put a blank log.txt file into your build directory and refactor the following code into main.lua:

releaseBuild is a global variable (nasty I know) to decide whether I want to actually print stuff to a file or not for the final build - simply define it above in main.lua and set to true or false.

if releaseBuild then  
 function print() end  
else  
 function print(statement)  
 local statement = statement  
 --print(tostring(statement))  
 local path = system.pathForFile( "log.txt", system.DocumentsDirectory )   
 local file = io.open( path, "a+" )  
  
 if type(statement) == 'table' then  
 local t = statement  
 for k,v in pairs(t) do  
 if type(v) == 'function' then  
 table.remove(t, k)  
 end  
 end  
  
 local jsonString = json.encode(t)  
  
 for k,v in pairs( t ) do  
 if v.type ~= 'function' then  
  
 file:write( k .. "=" .. v .. "," )  
 end  
 end  
 else  
 -- Creates the file where we save our data if needed  
 file:write(statement.."\n")  
 end  
  
 io.close( file )  
 end  
end  

You’ll have to download the xcappdata file from Xcode and click ‘Show Package Contents’ to actually be able to check out the log.txt file.

Seriously hoping Corona can work around the print obstacle to avoid having to log print statements to a file. [import]uid: 33275 topic_id: 31056 reply_id: 124699[/import]

@Stephen I tried the exact same thing as you with the same results. I’m in the same position right now myself: I can support landscapeRight or landscapeLeft, but not both at the same time AND not have GameCenter crash AND not have content switch to portrait mode when the device is put in that orientation. [import]uid: 36054 topic_id: 31056 reply_id: 125081[/import]

Everyone, please file a bug with Apple about the GameCenter crash. The more people who file this bug the sooner it will be fixed. [import]uid: 7559 topic_id: 31056 reply_id: 125129[/import]

I also experienced the same type of crash, not with Game Center, but by opening the device’s photo library using media.show( media.PhotoLibrary, sessionComplete) on a landscape-only restricted app. The fix noted above also fixes this crash.
[import]uid: 9422 topic_id: 31056 reply_id: 124818[/import]

@Tom,

As far as I can tell, the workaround isn’t working for me because of a problem with Corona. Unless I’m misunderstanding the information here http://developer.coronalabs.com/content/configuring-projects I should be able to lock Corona’s orientation (while allowing native UI elements to auto-rotate) by adding the content parameter in build settings. So the below should lock my Corona content to Landscape orientations while allowing the native stuff to auto rotate:

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

But what I’m seeing in the simulator and on iOS devices is the Corona content rotating to portrait orientations along with the native stuff. If this worked as I’m understanding the docs to describe then the workaround for the iOS 6 crash detailed above would work for me. Is this a bug or am I not understanding the purpose of the content parameter?

Also, it’s not clear to me why I need to set UIInterfaceOrientation and UISupportedInterfaceOrientations in the plist block. Isn’t that already being covered by the orientation block?

Thanks for any info you can provide. [import]uid: 9422 topic_id: 31056 reply_id: 125174[/import]

I had to modify the fix slightly to get my app to work in both landscape orientations. The original fix displays native objects correctly but all corona display objects are upside-down in one of the landscape orientations. Here’s the revised fix:

[code]
orientation =
{
default = “landscapeRight”,
content = {“landscapeRight”,“landscapeLeft”},
supported =
{
“landscapeRight”,“landscapeLeft”, “portrait”,
},

},
[/code] [import]uid: 9422 topic_id: 31056 reply_id: 124990[/import]

Blarg… maybe I spoke too soon. Following the advice here it seems that my Corona apps go into portrait orientation when I rotate the device (or simulator) left 90 degrees (curiously, rotation right works as expected).

Has anyone successfully worked around this issue - i.e. - iOS 6, landscape only orientations, native ui (game center, photo library, text boxes) not crashing, rotate left not causing screen orientation to change to portrait?

[import]uid: 9422 topic_id: 31056 reply_id: 125001[/import]

@Stephen I tried the exact same thing as you with the same results. I’m in the same position right now myself: I can support landscapeRight or landscapeLeft, but not both at the same time AND not have GameCenter crash AND not have content switch to portrait mode when the device is put in that orientation. [import]uid: 36054 topic_id: 31056 reply_id: 125081[/import]

Everyone, please file a bug with Apple about the GameCenter crash. The more people who file this bug the sooner it will be fixed. [import]uid: 7559 topic_id: 31056 reply_id: 125129[/import]

@Tom,

As far as I can tell, the workaround isn’t working for me because of a problem with Corona. Unless I’m misunderstanding the information here http://developer.coronalabs.com/content/configuring-projects I should be able to lock Corona’s orientation (while allowing native UI elements to auto-rotate) by adding the content parameter in build settings. So the below should lock my Corona content to Landscape orientations while allowing the native stuff to auto rotate:

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

But what I’m seeing in the simulator and on iOS devices is the Corona content rotating to portrait orientations along with the native stuff. If this worked as I’m understanding the docs to describe then the workaround for the iOS 6 crash detailed above would work for me. Is this a bug or am I not understanding the purpose of the content parameter?

Also, it’s not clear to me why I need to set UIInterfaceOrientation and UISupportedInterfaceOrientations in the plist block. Isn’t that already being covered by the orientation block?

Thanks for any info you can provide. [import]uid: 9422 topic_id: 31056 reply_id: 125174[/import]

frustrating. we planned to upload our nearly finished game whithin the next weeks. Game Center is deeply integrated and adds a high replay value to the game.

For time being, we could live with game center in portrait mode, while the rest of the game is in landscape mode. But unfortunately the workaround adds more problems.

Stephen already pointed out, that, using the workaround, ALL native elements will rotate when rotating the device … game center views, web views, native text fields…

Also, the game center view still leads to a crash (tested on a iPad2, iOS6) when opening game center in landscape view. But when holding the device in portrait position, game center opens (in landscape mode!), it doesn’t crash and it even stays stable when rotating the device back to landscape position.

I hope Apple fixes this ASAP and we will be able to release the game as planned. *keeping fingers crossed*

-finefin [import]uid: 70635 topic_id: 31056 reply_id: 125732[/import]

I hope everyone is filing a bug with Apple so the GameCenter and PhotoPicker crash get fixed. There is nothing we an do on this end to resolve the problem. [import]uid: 7559 topic_id: 31056 reply_id: 125751[/import]

There are (native) workarounds suggested at StackOverflow for this issue. Is this something that Corona SDK could implement?

http://stackoverflow.com/questions/12522491/crash-on-presenting-uiimagepickercontroller-under-ios6/12575058#12575058
[import]uid: 48484 topic_id: 31056 reply_id: 125901[/import]

frustrating. we planned to upload our nearly finished game whithin the next weeks. Game Center is deeply integrated and adds a high replay value to the game.

For time being, we could live with game center in portrait mode, while the rest of the game is in landscape mode. But unfortunately the workaround adds more problems.

Stephen already pointed out, that, using the workaround, ALL native elements will rotate when rotating the device … game center views, web views, native text fields…

Also, the game center view still leads to a crash (tested on a iPad2, iOS6) when opening game center in landscape view. But when holding the device in portrait position, game center opens (in landscape mode!), it doesn’t crash and it even stays stable when rotating the device back to landscape position.

I hope Apple fixes this ASAP and we will be able to release the game as planned. *keeping fingers crossed*

-finefin [import]uid: 70635 topic_id: 31056 reply_id: 125732[/import]

I hope everyone is filing a bug with Apple so the GameCenter and PhotoPicker crash get fixed. There is nothing we an do on this end to resolve the problem. [import]uid: 7559 topic_id: 31056 reply_id: 125751[/import]

If I understand it correctly, the workaround above just allows the app to rotate to portrait mode, and our app is designed to work in landscape mode only, thus the workaround is not acceptable.

There are already a *true* workaround out there which can only be implemented in native code. It seems Unity already shipped a version with it built in.
http://stackoverflow.com/a/12427983
http://unity3d.com/unity/whats-new/unity-3.5.6

Many games in App Store which are optimized for iPhone 5 and run in landscape only already run seamlessly with Game Center, and we can’t ship our game if it looks ugly in portrait.

Is there any good reason for Corona not to have the workaround built in? [import]uid: 132466 topic_id: 31056 reply_id: 126092[/import]

@orz, the workaround does keep you game in landscape mode and allows the GameCenter to run in portrait mode when needed. The only problem with that solution is all native objects (e.g., textFields and textBoxes) would also rotate to Portrait mode while the rest of your app was in landscape.

We have looked at some native code solutions and they still allow native objects to rotate, so that’s no better than what we have now. We also looked at subclassing the GCK but that has a high chance of being rejected by Apple.

The Unity link didn’t mention anything about GC, just that it fixed iOS6 orientation bugs so I don’t really know if they found a solution.

The Stackoverflow link talked about a fix but in the end they admitted that there were still problems:
“Yes, like it’s written in the post title problem appears in “GameCenter authentication in landscape-only”. It seems that GC just doesn’t have landscape assets for auth screen for iphone in ios6, so I suspect you won’t find a real solution - only workaround described here. That is why you have to allow app to launch in portrait mode when GC wants - but deny portrait in your main view - if you don’t want portrait of course. By the way, there is no such a problem in ipad on ios6. – Tertium yesterday”

We are trying to find a solution that works but in the end Apple has to fix this issue. [import]uid: 7559 topic_id: 31056 reply_id: 126118[/import]