关于此问题已经发布了很多问题,在Gamecenter VC
上按完后会出现在控制台中。所以,我会把它重新引起注意,因为它仍在发生,而其他问题没有答案:
插件com.apple.GameCenterUI.GameCenterDashboardExtension无效
我的代码:
viewDidLoad
中的身份验证:
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
if (viewController != nil)
{
[self presentViewController:viewController
animated:YES
completion:nil];
}
};
在IBAction
中提交分数并打开排行榜:
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
if (localPlayer.authenticated) {
NSUInteger highscore = [self retrieveHighscore];
GKScore *gkScore = [[GKScore alloc] initWithLeaderboardIdentifier:@"Leaderboard" player:localPlayer];
gkScore.value = highscore;
[GKScore reportScores:@[gkScore] withCompletionHandler:^(NSError * _Nullable error) {
}];
GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
if (gameCenterController != nil) {
gameCenterController.gameCenterDelegate = self;
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeAllTime;
gameCenterController.leaderboardIdentifier = @"Leaderboard";
[self presentViewController: gameCenterController animated: YES completion:nil];
}
}
任何解决方案?提前谢谢。