如何从我的应用程序运行iPhone GameCenter应用程序?

问题描述:

我认为最好的方法,可能是唯一的方法是与[[UIApplication sharedApplication] openURL:...]一起使用URL方案。但我无法找到游戏中心的URL方案。如何从我的应用程序运行iPhone GameCenter应用程序?

您可以通过使用gamecenter: URL方案推出的Game Center应用程序:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]]; 

尝试使用Apple示例代码。它解释了您的应用程序如何与gamecenter一起工作。 http://developer.apple.com/library/ios/#samplecode/GKTapper/Introduction/Intro.html

+0

这不是我所需要的,我知道如何与游戏中心合作,但我的客户希望有可能将用户从他的应用程序直接重定向到GameCenter应用程序 – 2011-04-20 07:19:55

在iOS的6.0有一个新的方式相当冷静使用GKGameCenterViewController显示游戏中心。

使用它您的视图控制器必须作为一个代表到GKGameCenterViewController:

@interface ViewController : UIViewController <GKGameCenterControllerDelegate> 

然后用于显示游戏中心观点:

- (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方案。