[iOS] GameCenter ShowLeaderboard() crash

Monkey Forums/Monkey Bug Reports/[iOS] GameCenter ShowLeaderboard() crash

Shinkiro1(Posted 2013) [#1]
Like described in this thread: http://www.monkeycoder.co.nz/Community/posts.php?topic=5566

When I call ShowLeaderboard() and the app is only landscape enabled it will crash the app.


marksibly(Posted 2013) [#2]
I can't reproduce this in ios 5/6 - again!

Can you try this:

* Open the example for gamecenter from the docs.

* Build for iOS.

* Open xcode project in xcode.

* Deselect portrait modes from 'Supported interface Orientations'.

* Change info-plist bundle id to appropriate value for itunes connect.

Build and run.

All seems to work fine here. The leaderboard shows correctly in landscape mode on both my ios 5 ipad1 and ios 6 ipod. Portrait mode is only used on ios 6 ipod to log user in if necessary and it seems to work fine - app rotates to login dialog and rotates back when done.

Could be an ios 7 only thing - but is that even finished yet?


Shinkiro1(Posted 2013) [#3]
Ok, I now narrowed it down to this:

It only fails when you are not logged in, have only landscape mode enabled and it shows the login screen (so also when using StartGamecenter). Then it will throw this exception:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'



I have tried the example from the docs with the above steps but it makes no difference.

I have tried this with Xcode 4.6 + ios6 sdk and with the new xcode 5 DP3 + ios7 sdk which both yield the same result on my ios6 device.

Edit:
According to this: http://stackoverflow.com/questions/12520030/how-to-force-a-uiviewcontroller-to-portait-orientation-in-ios-6
ShouldAutorotateToInterfaceOrientation is deprecated in ios6.

Edit2:
Everything else relating game-center works fine so my settings should be alright?


marksibly(Posted 2013) [#4]
Can you send me a zip of the docs example .build folder?

Is this iphone/ipad/ipod?

Device or simulator?


Shinkiro1(Posted 2013) [#5]
Ok, finally got it to work. I'm still using v70 so I don't know if this has been fixed in v74a.

In iosgame.cpp (templates) around line 592 I added these 2 methods:

@implementation BBMonkeyViewController

-(NSUInteger)supportedInterfaceOrientations {
	return UIInterfaceOrientationMaskAllButUpsideDown;
}

-(BOOL)shouldAutorotate {
	return [[UIDevice currentDevice] orientation] != UIInterfaceOrientationPortrait;
}


Of course you have to comment out the original supportedInterfaceOrientations Method.
Now in XCode make sure Portrait is enabled.
Source: http://bufordtaylor.com/post/32570935670/fixing-orientation-cocos2d-ios6

This might not be the best solution but if you need GameCenter login and your app is landscape only this will work.

Edit:
@Mark: It is an iPhone 4 device with ios6.


marksibly(Posted 2013) [#6]
I still can't get it to fail - can you please send me a zip of an ios build of the gamecenter example that fails?

This stuff is *extremely* (stupidly) delicate - I found one incredibly minor thing in the way the interface builder stuff was set up last week that caused auto rotation to fail on iOS 4.3.

Fixed now, but I want to be very careful on what I add here.


Shinkiro1(Posted 2013) [#7]
I will send you a copy in a week or so, need to get my game out first :)