How to run iphone GameCenter app from my app?

非 Y 不嫁゛ 提交于 2019-12-21 13:06:13

问题


I think the best way and may be only way is using the URL schemes with [[UIApplication sharedApplication] openURL:...]. But I can't find URL scheme for game center..


回答1:


You can launch the Game Center app by using the gamecenter: URL scheme:

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



回答2:


In iOS 6.0 there's a new way quite cool to show Game Center using GKGameCenterViewController.

For using it your view controller must acts as a delegate to the GKGameCenterViewController:

@interface ViewController : UIViewController <GKGameCenterControllerDelegate>

And then for displaying the Game Center view:

- (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];
}

If the user it's under iOS 5.0, you can only use the URL schemes like you said before.




回答3:


Try the Apple example code. It explain how your app work with gamecenter. http://developer.apple.com/library/ios/#samplecode/GKTapper/Introduction/Intro.html



来源:https://stackoverflow.com/questions/5702039/how-to-run-iphone-gamecenter-app-from-my-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!