应该使用ios7中的游戏中心报告得分
[GKLeaderboard reportScores:scores withCompletionHandler:^(NSError *error) {
//Do something interesting here.
}];
Run Code Online (Sandbox Code Playgroud)
但是,我在GKLeaderboard中找不到对此方法的任何引用.
此方法不存在:https: //developer.apple.com/library/ios/documentation/GameKit/Reference/GKLeaderboard_Ref/Reference/Reference.html
GKLeaderboard.h也不包含reportScores方法.
之前使用GKScore的reportScoreWithCompletionHandler方法报告得分的方式已被弃用,因此我不愿意使用它.
有谁知道在ios7中向游戏中心报告得分的正确方法是什么?
Gre*_*reg 15
我可以确认reportScores:withCompletionHandler:方法确实有效; 我在我的一个应用程序中使用它.它位于头文件GKScore.h中.这就是我使用它的方式:
- (void) reportHighScore:(NSInteger) highScore {
if ([GKLocalPlayer localPlayer].isAuthenticated) {
GKScore* score = [[GKScore alloc] initWithLeaderboardIdentifier:MY_LEADERBOARD_ID];
score.value = highScore;
[GKScore reportScores:@[score] withCompletionHandler:^(NSError *error) {
if (error) {
// handle error
}
}];
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5013 次 |
| 最近记录: |