2011-11-28 60 views
0

我創建了一個小應用程序只是爲了測試出遊戲中心我登錄,我能夠增加得分,但是當我看領先榜無所不有排行榜分數沒有顯示出來

這裏是我的代碼

- (IBAction)increaseScore:(id)sender { 

currentScore+=4; 
scoreLabel.text=[NSString stringWithFormat:@"%i",currentScore]; 
} 

- (IBAction)showLeaderBoard:(id)sender { 

GKLeaderboardViewController *leaderBoardController = [[GKLeaderboardViewController alloc]init]; 
[email protected]"1"; 
leaderBoardController.timeScope=GKLeaderboardTimeScopeAllTime; 
leaderBoardController.leaderboardDelegate=self; 

[self presentModalViewController:leaderBoardController animated:YES]; 

} 
- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController 
{ 
[self dismissModalViewControllerAnimated:YES]; 

} 


- (IBAction)sumbitScore:(id)sender { 

GKScore *scoreReporter = [[GKScore alloc]initWithCategory:@"1"]; 
//@"1" is the leaderboard ID 
scoreReporter.value=currentScore; 
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) { 
    if (error) { 
     NSLog(@"submit failed"); 
    }else{ 

     NSLog(@"access granted"); 

    } 

}]; 

} 
+0

而且我正在獲取@「授予訪問權限」而不是錯誤 – ifrapps

回答

1

當排行榜上有兩個或更多玩家時,GameCenter將只顯示排行榜得分。

您將需要由另一個GameCenter帳戶提交的分數。您可以註冊第二個Apple ID,以便能夠從「第二」播放器發送分數。