2016-02-26 86 views
0

這是我的代碼,在遊戲中心獲得默認排行榜,但返回零值。GameCenter iOS排行榜標識

我在iTunes中有這個信息連接我該怎麼辦?感謝

此圖片從iTunes連接

This image is from iTunes Connect

這是在Xcode This is from Xcode

這是從設備 This is from device

和獲得默認排行榜的代碼

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; 
      } 
     } 

    }; 

回答

1

你的代碼看起來很好。您是否嘗試在設備上註銷並重新進入Game Center?我在沙盒模式中也發生過幾次這種情況,並且退出並返回通常會修復它。

0

我解決了這個奇怪的問題,創建一個新的排行榜,並創建了我的應用程序的新版本例如1.1,這對我很有用。

謝謝您的回答crashoverride777

+0

MH。仍然不適合我:/ – John