如何从我的应用程序运行iphone GameCenter应用程序?
我认为最好的方法可能只是使用[[UIApplication sharedApplication] openURL:…]的URL方案。 但我找不到游戏中心的URL方案..
您可以使用gamecenter:
URL方案启动Game Center应用程序:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]];
在iOS 6.0中,使用GKGameCenterViewController显示Game Center是一种很酷的方式。
要使用它,您的视图控制器必须充当GKGameCenterViewController的委托:
@interface ViewController : UIViewController
然后显示Game Center视图:
- (void)showGameCenter { GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init]; if (gameCenterController != nil) { gameCenterController.gameCenterDelegate = self; [self presentViewController: gameCenterController animated: YES completion:nil]; } } //Called when the player is done interacting with the GKGameCenterViewController - (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController { [self dismissViewControllerAnimated:YES completion:nil]; }
如果用户在iOS 5.0下,您只能使用之前说过的URL方案。
试试Apple示例代码。 它解释了您的应用如何使用gamecenter。 http://developer.apple.com/library/ios/#samplecode/GKTapper/Introduction/Intro.html