gpt4 book ai didi

ios - dismissViewController 完成 :, 需要加载功能,无法使其工作

转载 作者:行者123 更新时间:2023-11-29 03:00:16 25 4
gpt4 key购买 nike

GameListViewController 中调用代码:

[self presentViewController:[[StartNewGameViewController alloc] 
initWithNibName:@"StartNewGameViewController" bundle:nil] animated:YES completion:nil];

StartNewGameViewController 中的回调代码:

[(id)self.parentViewController showSetup:m_tableID];
[self dismissViewControllerAnimated:YES completion:^{
[GLVC showSetup:m_tableID];
}];

也试过:

[(id)self.GLVC showSetup:m_tableID];

在这里尝试了上面三种不同的方法。第一种方法没有错误,底部方法说 show Setup has no known class method,第三种方法也没有错误。第一个和第三个没有错误,但没有工作。

StartNewGameController

.h

#import "GamelistViewController.h"
@property (nonatomic, assign) GamelistViewController *GLVC;

然后我在 .m

的顶部合成了 GLVC

“showSetup”是一种在 GameListViewController 中调用时工作正常的方法,它在 GameListViewController.h 中声明如下:

-(void)showSetup:(int)tableID;

我见过一些与此相关的其他堆栈溢出问题,但没有一个解决了我的问题。

最佳答案

[(id)self.parentViewController showSetup:m_tableID];

之所以有效,是因为对 parentViewController 的引用是自动为您配置的。

[GLVC showSetup:m_tableID];

应该是 _GLVC 或者,最好是 self.GLVC 并且不起作用,因为您在呈现 View Controller 之前从未设置引用。 (以前它不起作用,因为您使用的是类名,由于命名错误,期望它是实例变量名,但事实并非如此)。

[(id)self.GLVC showSetup:m_tableID];

实际上与上面的相同(在您新编辑的代码中)。

解决方案是在调用 presentViewController:animated:completion:

之前在创建的 View Controller 上设置 GLVC
StartNewGameViewController *svc = [[StartNewGameViewController alloc] initWithNibName:@"StartNewGameViewController" bundle:nil];
svc.GLVC = self;

[self presentViewController:sec animated:YES completion:nil];

关于ios - dismissViewController 完成 :, 需要加载功能,无法使其工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23390541/

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