游戏中心“完成”按钮不起作用

发布于 2025-01-02 17:36:52 字数 711 浏览 2 评论 0原文

我正在显示游戏中心排行榜,但它出现后我无法将其关闭 - “完成”按钮不起作用。

这是我的 RootViewController.m 代码:

-(void) showLeaderboard {
    GKLeaderboardViewController *leaderboardVC [GKLeaderboardViewController alloc] init] autorelease];
    if (leaderboardVC != nil) {
        [leaderboardVC setDelegate: self];
        [leaderboardVC setCategory: kLeaderboardID];
        [leaderboardVC setTimeScope: GKLeaderboardTimeScopeWeek];
        [self presentModalViewControllerAnimated: YES];
    }
}

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

​​ 同样奇怪的是我从未在日志中看到“关闭排行榜”。

I am showing a Game Center Leaderboard but after it appears I can't close it—the "Done" button doesn't work.

Here is my code for RootViewController.m:

-(void) showLeaderboard {
    GKLeaderboardViewController *leaderboardVC [GKLeaderboardViewController alloc] init] autorelease];
    if (leaderboardVC != nil) {
        [leaderboardVC setDelegate: self];
        [leaderboardVC setCategory: kLeaderboardID];
        [leaderboardVC setTimeScope: GKLeaderboardTimeScopeWeek];
        [self presentModalViewControllerAnimated: YES];
    }
}

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

What's also strange is that I never see "Close leaderboard" in the log.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相权↑美人 2025-01-09 17:36:52

您是否将 GKLeaderboardViewControllerDelegate 添加到此类实现的协议列表中? (leaderboardViewControllerDidFinish 是此协议中的唯一方法)。你的代码看起来很完美,所以这是我唯一能想到的。

Did you add GKLeaderboardViewControllerDelegate to the list of protocols that this class implements? (leaderboardViewControllerDidFinish is the only method in this protocol). Your code looks perfect so this is the only thing I can think of.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文