Game Development Reference
In-Depth Information
rather annoying for landscape apps, but there seems to be no obvious way to change
this behavior via methods or properties of the view itself.
To allow the Game Kit views to be presented in landscape orientation, you have to ex-
tend each Game Kit view with a category and implement (override) the
shouldAutorotateToInterfaceOrientation method. You then have it re-
turn YES for all the interface orientations the view is allowed to autorotate to. You can
use the method UIInterfaceOrientationIsLandscape to force the Game Kit
views to be presented in landscape orientation. The following code is an implementa-
tion that forces the GKLeaderboardViewController view to display itself in
landscape orientation:
@interface GKLeaderboardViewController (OrientationFix)
-(BOOL) shouldAutorotateToInterfaceOrientation:←
@implementation GKLeaderboardViewController (OrientationFix)
-(BOOL) shouldAutorotateToInterfaceOrientation:←
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
You can apply the same principle to the GKAchievementViewController , the
GKMatchmakerViewController and in general to any self-contained, ready-
made view controller. This procedure is the only way to force a specific orientation on
Game Kit views, and it's not a hack but the recommended (and only) solution.
In the IsoTilemap04 project you're also calling the GameKitHelper
showAchievements method when the leaderboard view is dismissed. This brings
up the Achievements view ( Listing 14-13 ).
Listing 14-13 . Showing the Achievements View
Search Nedrilad ::

Custom Search