游戏中心领导板上的完成按钮不起作用

时间:2014-07-20 20:41:41

标签: objective-c ios7 delegates leaderboard

当我在排行榜视图中按下完成按钮时,它不会执行任何操作并且排行榜仍然可见。

这是代码:

GKGameCenterViewController *gcViewController = [[GKGameCenterViewController alloc] init];

gcViewController.gameCenterDelegate = self;
[gcViewController setDelegate:self ];
if (shouldShowLeaderboard) {
    gcViewController.viewState = GKGameCenterViewControllerStateLeaderboards;
    gcViewController.leaderboardIdentifier = currentLeaderBoard;
}
else{
    gcViewController.viewState = GKGameCenterViewControllerStateAchievements;
}

[self presentViewController:gcViewController animated:YES completion:nil];**

2 个答案:

答案 0 :(得分:5)

你必须添加函数来关闭视图控制器(委托)

-(void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController{
[gameCenterViewController dismissViewControllerAnimated:YES completion:nil];

}

答案 1 :(得分:0)

对我有用的是将GKGameCenterControllerDelegate添加到协议列表中。