shouldAutorotateToInterfaceOrientation Depreciated

Monkey Forums/Monkey Bug Reports/shouldAutorotateToInterfaceOrientation Depreciated

benmc(Posted 2012) [#1]
shouldAutorotateToInterfaceOrientation on iOS has been depreciated in iOS 6 which is causing all apps to auto rotate to unsupported orientaitons.

This is called in main.mm

The problem: even if you have your only supported orientations set to Landscape, it will still auto-rotate to portrait.

I believe this is because shouldAutorotate is returning YES and shouldAutorotateToInterfaceOrientation replaced with supportedInterfaceOrientations.

To recreate this error, create a Landscape app, build for iOS, and build in XCode 4.5 and run on an iOS 6 emulator or device. You'll notice it makes it portrait view instead of landscape.


benmc(Posted 2012) [#2]
[deleted]

Was a link to login-only area.


marksibly(Posted 2012) [#3]
Hi,

I can't actually access that link...but I think I've got it fixed.

I've also fixed the problem where MonkeyGames weren't appearing in the ios6 simualtor.


benmc(Posted 2012) [#4]
Oh awesome, thank you! Looking forward to the update.


mulawa1(Posted 2012) [#5]
Hi Mark,

I've just started on a new Mac with Xcode 4.5 and Monkey v66.

There is still an issue here - true my app works fine on the iPad 6 emulator but on my real iPad 5 the problem still exists.

This link though beyond me may help:

http://stackoverflow.com/questions/12717951/xcode-4-5-ios6-orientation-issue-with-my-ipad-app-in-landscape-mode

Regards ... Peter


benmc(Posted 2012) [#6]
Yes, same problem with me. It's now working well on iOS 6 devices, but it's not rotating correctly on iOS 5 devices now. I had to edit the shouldAutorotateToInterfaceOrientation function so that it always returns just a single landscape orientation.


mulawa1(Posted 2012) [#7]
I've decided that rather than being at the mercy of Apple changing the rules my apps will run in any orientation. If a user rotates to portrait my landscape app rescales to fit in the top half of the portrait display.

I was surprised how easy this was to do and how well it works.


marksibly(Posted 2012) [#8]
Hi,

I still can't reproduce this.

Here's what I'm doing step by step:

1) Delete bananas/mak/bouncyaliens .build dir.

2) Build bouncyaliens.

3) Open monkeygame.xcodeproj.

4) Disable portrait supported orientations - this is on the first page I see when xcode opens. 2 clicks to disable portrait and upside down...

5) Build and run on my iPad 1 device/ios 5.1.1 .

6) Scratch head and wonder why it's not working for others...


benmc(Posted 2012) [#9]
@mulawa1 I found a configuration that seems to stop it from using portrait, but I can't control the initial interface orientation any longer.

1) In the plist.info, I left Supported Interface Orientations in the order of: left home button first, then right home button.

2) I cannot have an initial interface orientation option at all, it breaks it completely.

3) I made my launch images rotated for left home button orientations.

4) In the .mm file, I had to comment out the 2 portrait interfaceOrientation cases in shouldAutorotateToInterfaceOrientation

5) For supportedInterfaceOrientations I had to return ONLY UIInterfaceOrientationMaskLandscape

This seemed to do the trick, but I could not set an initial interface orientation which is a bummer.

I also had to leave in the Portrait modes in the Summary to support Game Center on iOS 6 as a requirement.



@marksibly Try the iPhone simulators, and to see it break, just add an initial interface orientation, or change the order of the supported interface orientations. Also try to do a Rotate Left or Right of the device simulator.

I'll try to get some screenshots of what's happening, or maybe a video.


Gerry Quinn(Posted 2012) [#10]
mulawa1 said: "I've decided that rather than being at the mercy of Apple changing the rules my apps will run in any orientation. If a user rotates to portrait my landscape app rescales to fit in the top half of the portrait display.

I was surprised how easy this was to do and how well it works."


I guess it depends on the game. Personally I hate when things autorotate based on the way I am holding the tablet.


marksibly(Posted 2012) [#11]
Hi,

Ok, could you please describe as precisely as possible what you are trying to do, eg:

* What supported orientations do you want to allow?

* What should the initial orientation be?


benmc(Posted 2012) [#12]
I'll try. The work-around I described pretty much solves the issue with the exception of being able to set an initial interface orientation.

I was trying to get my games to stay in landscape mode, but as soon as I changed the initial interface orientation, it would allow the game to rotate to portrait, or worst case, it would auto-rotate it to portrait even tho the device appeared in landscape - which was very odd.

I'll try to put together exact steps for you with the bouncy aliens example. Thank you for your patience with this.


anawiki(Posted 2012) [#13]
I'd like to point out that benmc is not the only one with this problem. Our games have the same issue and we tried a lot of things suggested in this thread. We need landscape orientation only allowed and landscape orientation at the start (without autoration from portrait at the start).

Also, on iPod 4g with iOS 6.0.1 the game works only with all orientations allowed. If I turn off portrait orientations the game doesn't start.


marksibly(Posted 2012) [#14]
Hi,

> @mulawa1 I found a configuration that seems to stop it from using portrait, but I can't control the initial interface orientation any longer.

What configuration is this? You shouldn't really have to configure anything - just click/disable the 2 'portrait' icons in 'supported interface orientations' in xcode. This should automatically change the info.plist so you shouldn't have to edit that as well. You shouldn't have to set initial interface orientation either.

> I'd like to point out that benmc is not the only one with this problem.

Does it also happen with bouncyaliens if you follow the steps I posted above? So far, no one has confirmed it's also happening with bouncyaliens so I have very little to go on.

If it *isn't* happening with bouncyaliens but it *is* happening with your app, could you please email me the project?

If it *is* happening with bouncyaliens, please reply here along with as much system/xcode/ios version info as you can.


benmc(Posted 2012) [#15]
Yes, you can get it to happen with bouncyaliens in the simulator.

If you want to use Game Center, you're required to leave the Portrait views active in the Summary because iOS 6's Game Center login is in portrait.

So if you leave those active, and start the app, then rotate your device to portrait, the whole game rotates to portrait.

The problem I have with resizing is because I setup my scale ratio in OnCreate instead of every time in onRender like bouncyaliens does. So bouncyaliens doesn't necessarily look odd when rotating, but it does rotate.

I think what would be nice is if we could define the app as Landscape in the Monkey Config vars, but not have to disable the portrait views in the summary, but the autoOrientation functions would somehow make it so the app never rotated to portrait from there.

EDIT: And we really need to be able to set an initial interface orientation too because otherwise, the app does this flip flop thing to upside down, right side up, sometimes - depending on how someone is holding the device.


marksibly(Posted 2012) [#16]
Hi,

I don't think this is achieving much - could someone please email me something to actually test/run?


anawiki(Posted 2012) [#17]
OK, I'm sending you bouncy aliens project that replicates the issue.


benmc(Posted 2012) [#18]
Sorry Mark, as I type these things out, I know I'm not getting us anywhere :( I'm just not familiar enough with XCode to really know what's going wrong, all I know is that it is, and I keep tweaking things until something kind-of works.

Good idea anawiki, I could have just bundled the XCode project and sent it.