iOS 6 forcing apps to run in portrait mode?

Monkey Targets Forums/iOS/iOS 6 forcing apps to run in portrait mode?

benmc(Posted 2012) [#1]
I don't know what's going on, but I cannot get my apps to run in Landscape mode anymore.

I build for iOS

I update XCode and the plist file so only Landscape orientations exist, but no matter what, it always displays my apps in Landscape mode.

This only happened when updating to iOS 6 and the latest XCode.

Anyone know anywhere else in XCode it might be telling my app to run in portrait and override all the other Summary / Info settings?


benmc(Posted 2012) [#2]
I think I found something. It appears that shouldAutorotateToInterfaceOrientation has been replaced by 2 new methods:

http://stackoverflow.com/questions/12476273/xcode-4-5-ios-6-0-simulator-and-rotation-issues

Is this fixed in newer releases of Monkey already?


benmc(Posted 2012) [#3]
shouldAutorotateToInterfaceOrientation was depreciated in XCode 4.5 and iOS 6 which is where this problem is coming from.

Kind-of at a stand-still for testing on iOS until this is resolved so posted it to Bugs - hope that's the right protocol.


silentshark(Posted 2012) [#4]
I take it that this doesn't hit existing apps? I.e they are ok under ios6?


benmc(Posted 2012) [#5]
Correct, if an app is already available and built with a previous version of Xcode it should be fine, but at this time, with Xcode 4.5 and iOS 6 and the current version of Monkey, you can't build landscape apps because they only display in portrait.


Amnesia(Posted 2012) [#6]
Ok. I found a way to temporarily solve the issue, but this will have to be addressed by mark on an update.
If you want your game running in landscape mode on ios6, but it shows on portrait is mainly because the method shouldAutorotateToInterfaceOrientation on ios6 is deprecated. To fix this, first compile your game in monkey and open the project in xcode. Open the file main.mm. Search for shouldAutorotateToInterfaceOrientation. Delete that method and replace it with this code:
-(BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

The above code must be inside the implementation MonkeyViewController

Then search for:
[window addSubview:viewController.view]

And replace that line with:
window.rootViewController = viewController;


That should do it... for now


benmc(Posted 2012) [#7]
@Amnesia Thank you!

I couldn't figure out how to identify the rootViewController.

Did you leave shouldAutorotateToInterfaceOrientation in for older devices/os's?


Amnesia(Posted 2012) [#8]
I'm going to try now on an ios5 ipad.
Also, i noticed that in v66 is fixed


Amnesia(Posted 2012) [#9]
Yes, you need to keep the old shouldAutorotateToInterfaceOrientation method to keep ios5 compatibility


benmc(Posted 2012) [#10]
It appears that v66 does leave in shouldAutorotateToInterfaceOrientation as well. And it's building fine now in landscape on iOS 6.


Amnesia(Posted 2012) [#11]
And you need to keep both lines
[window addSubview:viewController.view];
window.rootViewController = viewController;