问题
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