[英]GameCenter iOS leaderboard identifier
這是我在游戲中心獲取默認排行榜但返回nil值的代碼。
並且我在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;
}
}
};
您的代碼看起來不錯。 您是否嘗試退出並在設備上重新登錄Game Center? 在沙盒模式下,我也遇到過幾次這種情況,通常先注銷然后重新登錄即可解決此問題。
我解決了這個奇怪的問題,創建了一個新的排行榜,並為示例1.1創建了我的應用程序的新版本,這對我來說很有效。
感謝您的回答crashoverride777
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.