shouldAutorotate code broken on iOS 5 devices now

Monkey Targets Forums/iOS/shouldAutorotate code broken on iOS 5 devices now

benmc(Posted 2012) [#1]
The recent update fixed the rotation problem when building to iOS 6, but now when I run the same code and build to my iOS 5 device, it's displaying in portrait mode only.

To hack this, I had to force the shouldAutorotateToInterfaceOrientation code to return a landscape orientation only, removing any portrait references.


marksibly(Posted 2012) [#2]
Hi,

This is working here with the 5.1 emulator (forgot to pay my Apple tax so I can't build for an actual device right now).

Have you changed 'Supported Interface Orientations' settings from xcode 'Deployment Info' page?

If I change supported orientations to/from portrait/landscape it seems to do what I'd expect...

Have you deleted .build dir?


benmc(Posted 2012) [#3]
I deleted the build folder when switched to v66, and that's when it built correctly to my iOS 6 device.

I plugged in an iOS 5.1 device and built to it, not changing any settings, and it flipped the orientation to portrait.

I have changed all the supported interface orientation settings I could find to only allow landscape.

I'm installing the simulator now for 5.1 to try it there.


benmc(Posted 2012) [#4]
UPDATE:

My simulators create the same problem.

When the app runs, the simulator is rotated to its landscape position, BUT everything inside is rotated to Portrait. So I really don't know what's going on.

In shouldAutorotateToInterfaceOrientation, it appears that interfaceOrientation is always UIInterfaceOrientationPortrait - even if the simulator is displaying on my screen as UIInterfaceOrientationLandscape


marksibly(Posted 2012) [#5]
Hi,

Ok, seems to work fine on an actual device here too.

Tried with a fresh download of v66, the bouncyaliens sample and a 5.1.1 iPad1.

MacOS 10.8.2
XCode 4.5
MonkeyV66
iPad1 5.1.1

What does bouncyaliens do on your setup by default? Can you rotate to any orientation?


benmc(Posted 2012) [#6]
Bouncy Aliens seems to work correctly in the simulator. I don't know, I'll try removing all my scaling and do exactly what's in bouncy alients and see if it makes a difference....

EDIT: OK, since the bouncy aliens were working and the scaling didn't seem to have anything to do with it, I found that I had to completely delete the project from the XCode Organizer, rebuild, and then it oriented correctly on iOS 5 and 6

Thanks for your help


benmc(Posted 2012) [#7]
I can't seem to figure out what to do with this.

On my iOS 6 devices, I don't have a problem, but I have to edit the orientation functions to force a landscape orientation.

However, on 5.x devices, I cannot stop it from allowing the device to rotate into a portrait view for a landscape app, and I've removed every portrait reference I can find.

Any help would be greatly appreciated.


benmc(Posted 2012) [#8]
As I experiment hour after hour, it seems that it's important that, for iOS 5.x devices that your initial interface orientation option be added to the plist file, and that it match the top option of the supported interface orientations.


benmc(Posted 2012) [#9]
FINALLY, I can give you some steps on how this bug is re-created.

If you take Bouncy Aliens, for example, build for iOS, and run in any simulator, it seems to work fine.

Now, in XCode, go to the plist file and move the Supported interface orientation options around, like put right home button above left home button, or add an Initial orientation option.

Run the app again in the iOS 5 simulator, and you'll see how it flips its orientation to portrait - even in landscape mode.

Once I make a change to the plist file, I can't seem to ever get it back to normal, I have to rebuild from scratch.

EDIT:

I've now gone through this experiment just about 50 times, and it appears that if you don't make Landscape, left home button, your initial interface orientation, it just doesn't work.


Chroma(Posted 2013) [#10]
Now this is happening to me too...ugh. First it was landscape and the game was rotated left. Now it's rotated right...


benmc(Posted 2013) [#11]
Yep, with the latest version it's not working correctly, especially since you have to leave Portrait enabled for Game Center login to work. I had to revert back to v67 to release my new game because of this and implement my tricks, and even then I couldn't get it not to rotate to portrait on the iPad regardless of the way I rotate the device, so I only released on iPhone.


anawiki(Posted 2013) [#12]
If your code requires Portrait enabled for Game Center login to work then you have incorrect implementation of Game Center. I just checked and in our game if shows in landscape correctly. For sure you can't use lame tricks to rotate GC view via CGRotate or whatever it is cold. You must correctly attach GC view to monkey view and it will work. I apologize for very few details, but I coded it over a year ago and haven't looked at it more.


benmc(Posted 2013) [#13]
You are correct, it loads Leaderboards in landscape OK, it's the Game Center Login screen on iPhone (not iPad) that requires Portrait be enabled.

If you log out of Game Center, disable all portrait views in your app, then open your game on an iPhone/iPod Touch - upon trying to log you into Game Center, it will crash your game because you have to have Portrait enabled for the Game Center login page to open.

I could technically leave Portrait out, and most of the time leaderboards and such will open fine, and users will be logged into game center automatically, but if someone isn't logged into Game Center for some reason, it will crash when my app opens as it tries to log them in.

So anyone who doesn't leave Game Center on or doesn't like it, my game is going to crash unless I leave Portrait enabled.

I think one fix would be to have a compiler directive such as

#IOS_SCREEN_LANDSCAPE = True

Then the rotation code could be setup to allow Portrait only if a window such as Game Center is opened, but in ALL other cases force the game back into Landscape mode. Right now it's still allowing Portrait to be returned as we leave it enabled in XCode for GC to work.

(Sorry for the rambling)


anawiki(Posted 2013) [#14]
OK, I just logged out from GC on my iPhone and run my game. Game starts in landscape and has only landscape enabled. GC login kicks in in portrait mode, but the game doesn't crash. I can login or cancel logging in and game works just fine.

Check out Runes of Avalon on your iPhone and see if it works as it should.