Ios 游戏中心-定位
Cocos2d版本:v0.99.04 我正在将Game Center添加到我当前的应用程序中,我找到了一些代码来打开GKMatchmakerViewController。它似乎工作得很好,除非当它被忽略时,它会将模拟器中的方向更改为纵向。游戏只在风景区进行。我将设备旋转回横向,所有cocos2d场景仍然可以正常工作,但如果我打开警报或对等选择器,它们将以纵向模式打开。我可以打开和关闭场景,但它们现在都将显示这种行为。使用实际设备也会发生这种情况Ios 游戏中心-定位,ios,cocos2d-iphone,game-center,Ios,Cocos2d Iphone,Game Center,Cocos2d版本:v0.99.04 我正在将Game Center添加到我当前的应用程序中,我找到了一些代码来打开GKMatchmakerViewController。它似乎工作得很好,除非当它被忽略时,它会将模拟器中的方向更改为纵向。游戏只在风景区进行。我将设备旋转回横向,所有cocos2d场景仍然可以正常工作,但如果我打开警报或对等选择器,它们将以纵向模式打开。我可以打开和关闭场景,但它们现在都将显示这种行为。使用实际设备也会发生这种情况 // *.h UIViewController *
// *.h
UIViewController *tempVC;
// *.m
// Open
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = 2;
request.maxPlayers = 2;
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = self;
tempVC=[[UIViewController alloc] init];
[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];
[tempVC presentModalViewController: mmvc animated: YES];
// Close
[tempVC dismissModalViewControllerAnimated:YES];
[tempVC.view removeFromSuperview];
[tempVC release];
只要我按下DismissModalViewController激活,模拟器就会旋转
提前感谢您的帮助。我也遇到了同样的问题(不使用cocos2d),我通过对游戏中心所连接的UIViewController进行子类化来解决这个问题:
@interface GameCenterViewController : UIViewController
{
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;
@end
@implementation GameCenterViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
// Does it match my screenOrientation?
if (sceneOrientation == (UIDeviceOrientation)toInterfaceOrientation)
return YES;
return NO;
}
@end
在
@implementation
@interface UINavigationController (Private)
- (NSUInteger)supportedInterfaceOrientations;
- (BOOL)shouldAutorotate;
@end
@implementation UINavigationController (Private)
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate
{
return YES;
}
@end