2012-03-02 119 views
0

這是我的第一個應用程序,包括gamecenter,我有一個小問題。 我實施了一些代碼,我發現應該工作的網絡。一切工作正常,除了「完成按鈕」 :(xcode「完成按鈕」GameCenter沒有做任何事情

.M

#import <GameKit/GameKit.h> 

    - (void)viewDidLoad { 
    [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) { 
      if (error == nil) 
       NSLog(@"Authentication Successful!"); 
      else 
       NSLog(@"Authentication Failed!"); 
     }]; 


-(IBAction)subscore{ 

    GKScore *scoreReporter = [[GKScore alloc] initWithCategory:@"lrhseasy"]; 
    scoreReporter.value = score; 
    [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) { 
     if (error != nil) { 
      NSLog(@"Submitting a score failed!"); 
     } 
     else { 
      NSLog(@"Submitting succeeded!"); 
     } 
    }]; 

} 
-(IBAction)showLeader{ 

    GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc]init]; 
    if (leaderboardController != nil) { 
     //leaderboardController.leaderboardDelegate = self; 
     [self presentModalViewController:leaderboardController animated:YES]; 
    } 

} 


    - (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController { 
     NSLog(@"Close leaderboard"); 
     [self dismissModalViewControllerAnimated:YES]; 
     [viewController.view.superview removeFromSuperview]; 
    } 

最後一個函數isn't叫,當進行按下按鈕 - 我不得到「接近排行榜」中調試控制檯。

搜尋3小時後,我發現的唯一的事情是 「你加GKLeaderboardViewControllerDelegate到協議列表中,這個類實現?」但我不知道這意味着什麼或如何了完成:(

回答

2

我有一個類似的問題,而是GKLeaderBoardViewControllerDelegate添加到您的協議列表中做到這一點:

@interface YourClass: NSObject <GKLeaderBoardViewControllerDelegate> { 

} 

@end