这是我在游戏中心获取默认排行榜但返回零值的代码。
我在 iTunes 连接中有此信息,我该怎么办?谢谢
此图片来自 iTunes Connect
以及获取默认排行榜的代码
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
if (viewController != nil) {
[self presentViewController:viewController animated:YES completion:nil];
}
else{
if ([GKLocalPlayer localPlayer].authenticated) {
_gameCenterEnabled = YES;
[[GKLocalPlayer localPlayer]loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString * _Nullable leaderboardIdentifier, NSError * _Nullable error) {
if (error != nil) {
NSLog(@"%@",[error localizedDescription]);
}else{
_leaderboardIdentifier = leaderboardIdentifier; // **This contains nil value**
}
}];
}else{
_gameCenterEnabled=NO;
}
}
};
最佳答案
您的代码看起来不错。您是否尝试在设备上退出并重新登录游戏中心?我在沙盒模式下也遇到过几次这种情况,注销并重新登录通常可以修复它。
关于ios - GameCenter iOS 排行榜标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35645612/