2011-12-15 10 views
0

私のアプリケーションに入力するgamecenterを にしたいので、テスト用のgamecenter用に新しいプロジェクト "gamecenter"を作成します "http://www.youtube.com/watch?v=9avpP0hYwik"ビデオを参照しました。しかし 私は ViewController.mはgamecenterでスコアを提出しません

ので:-(plzは 私のコードは

viewController.h

ある
アプリはgamecenterhelpでスコアを提出しない "自動解放" の削除
#import <UIKit/UIKit.h> 

@interface ViewController : UIViewController 
{ 
    IBOutlet UILabel *scoreText; 
    int *scoreInt; 
} 

-(IBAction)subScore:(id)sender; 
-(IBAction)showLeader:(id)sender; 
-(IBAction)addScore:(id)sender; 

@end 

のXcode 4.2を使用します

#import "ViewController.h" 
#import <Gamekit/Gamekit.h> 


@implementation ViewController 

-(IBAction)subScore:(id)sender 
{ 
    GKScore *scoreReporter = [[GKScore alloc] initWithCategory:@"1234567"]; 
    scoreReporter.value = scoreInt; 

    [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) { 
     if (error != nil) 
     { 
      NSLog(@"failed"); 
     } 
     else 
     { 
      NSLog(@"Succeeded"); 
     } 
    }]; 
} 
-(IBAction)showLeader:(id)sender 
{ 
    GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; 
    if (leaderboardController != nil) 
    { 
     leaderboardController.leaderboardDelegate = self; 
     [self presentModalViewController:leaderboardController animated:YES]; 
    } 
} 

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

-(IBAction)addScore:(id)sender 
{ 
    scoreInt +=1; 
    NSString *clicks = [NSString stringWithFormat:@"%d", scoreInt]; 
    scoreText.text = clicks; 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) { 
     if (error == nil) 
     { 
      NSLog(@"Authentication Successful!"); 
     } 
     else 
     { 
      NSLog(@"Authentication Failed!"); 
     } 
    }]; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 
} 

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
} 

- (void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:animated]; 
} 

- (void)viewDidDisappear:(BOOL)animated 
{ 
    [super viewDidDisappear:animated]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

@end 

答えて

0

あなたのリーダーボードのカテゴリIDは正しいですか?

リクエストブロックにエラーメッセージが表示されますか?

非同期リクエストブロックに応答がない場合は、gamecenterがリクエストを処理する準備ができていないことを意味します。リーダーボードを作成したばかりの場合は、数時間待つ必要があります。

関連する問題