我尝试用Game Center展示我的游戏排行榜。 当我点击游戏中的游戏中心按钮时,会调用以下内容:
- (void)showGameCenterButtonPressed:(id)sender {
{
if ([GKLocalPlayer localPlayer].authenticated == NO) {
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"You must enable Game Center!"
message:@"Sign in through the Game Center app to enable all features"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
} else {
GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
if (gameCenterController != nil)
{
gameCenterController.gameCenterDelegate = self;
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
gameCenterController.leaderboardIdentifier = @"MyScore";
UIViewController *vc = self.view.window.rootViewController;
[vc presentViewController: gameCenterController animated: YES completion:nil];
}
}
}
}
我还有一个报告分数方法:
-(void)reportScore {
if ([GKLocalPlayer localPlayer].isAuthenticated) {
GKScore *scoreReporter = [[GKScore alloc] initWithLeaderboardIdentifier:@"MyScore" forPlayer:[GKLocalPlayer localPlayer].playerID];
scoreReporter.value = _highScore;
NSLog(@"Score reporter value: %@", scoreReporter);
[GKScore reportScores:@[scoreReporter] withCompletionHandler:^(NSError *error) {
if (error != nil) {
NSLog(@"Error");
// handle the reporting error
}
}];
}
}
现在游戏中心窗口向上滑动,显示游戏标题,但说“没有排行榜”
我认为这可能是iTunes Connect问题..但Bundle Identifier是正确的,但Game Center已启用。有什么想法吗?非常感谢!