GameKit orientation problem
When my app runs in landscape (which it always does) I have problems with the GameKit view - if I hold the phone in portrait orientation, the GameKit view appears offsc开发者_JS百科reen, if I hold it in landscape view it appears sideways up, ie, in its own landscape mode but at 90 degrees to the calling view controller's. I've been trying to find solutions for days, the only thing which works (as long as the user keeps the phone in landscape orientation) is -
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
followed by -
leaderboardController.view.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0.0f));
[leaderboardController.view setCenter:CGPointMake(240, 160)];
Trouble is, if the user holds the phone in portrait orientation, the Game Center appears at 90 degrees again, in its own portrait mode. Help! Any words of wisdom greatly appreciated.
Hmm... i had the same problems too.. But i was using cocos2d to make my game.. Not sure what engine you are currently using or for what purpose..
But for my cocos2d.. here's my code..
mmvc.view.transform = CGAffineTransformMakeRotation( CC_DEGREES_TO_RADIANS( 90.0f ) );
mmvc.view.bounds = CGRectMake(0, 0, 480, 320);
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight];
精彩评论