gpt4 book ai didi

ios - 无法关闭 Game Center 排行榜页面

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:04:07 24 4
gpt4 key购买 nike

我可以毫无问题地加载排行榜。但是当单击“完成”按钮时我无法关闭它。

我是如何打开它的:

- (IBAction)leaderboardsClicked:(id)sender{
if ([GKLocalPlayer localPlayer].isAuthenticated) {
GKGameCenterViewController *leaderboardController = [[GKGameCenterViewController alloc] init];
[self presentViewController:leaderboardController animated:YES completion:NULL];
}else{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Error"
message: @"You must be logged into Game Center to view the leaderboards. Open Game Center?"
delegate: self
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes",nil];
[alert show];
}
}

我如何关闭它:

- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController{
NSLog(@"test");
[self dismissViewControllerAnimated:YES completion:nil];
}

编辑:

该方法根本没有运行;所以“测试”甚至不会被打印出来。

然后我添加了 <GKGameCenterControllerDelegate>到我的 ViewController 的协议(protocol)。

最佳答案

试试这个:

- (IBAction)leaderboardsClicked:(id)sender{
if ([GKLocalPlayer localPlayer].isAuthenticated) {
GKGameCenterViewController *leaderboardController = [[GKGameCenterViewController alloc] init];
leaderboardController.gameCenterDelegate = self;
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;

[self presentViewController:leaderboardController animated:YES completion:NULL];
}else{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Error"
message: @"You must be logged into Game Center to view the leaderboards. Open Game Center?"
delegate: self
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes",nil];
[alert show];
}
}

和:

- (void) gameCenterViewControllerDidFinish:(GKGameCenterViewController*) gameCenterViewController {
[self dismissViewControllerAnimated:YES completion:nil];
}

关于ios - 无法关闭 Game Center 排行榜页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25577584/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com