我有這個代碼將我的分數提交給遊戲中心,但是每當我在遊戲中心內提交分數時,就會說我的分數是0.我不確定這是怎麼發生的?我也導入了GameKit框架。我查看了幾個教程,這些教程都來自Xcode的先前版本,但我不確定這是否有所作爲。GameCenter - 向遊戲中心提交分數的代碼不起作用 - Xcode - iOS
-(IBAction)submitScore{
if (highscore>0) {
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:@"MyLeaderBoardID"] autorelease];
scoreReporter.value = [[NSNumber numberWithInt:highscore] longLongValue];
NSLog(@"posted");
NSLog(@"%i",highscore);
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
{
NSLog(@"failed!!!");
NSLog(@"%i",highscore);
}
else{
NSLog(@"Succeded");
}
}];}
我也有這個代碼簽署:
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error){
if (error == nil) {
NSLog(@"authintication success");
}
else{
NSLog(@"authintication failed");
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Game Center Disabled"message:@"For Game Center make sure you have an account and you have a proper device connection."delegate:self cancelButtonTitle:@"Ok"otherButtonTitles:nil];
[alert show];
}
}]。
self.currentLeaderBoard = @"MyLeaderBoardID";
這是如何從2012年5月提供的答案有什麼不同? – EWit 2014-09-16 14:51:32