gpt4 book ai didi

ios - 当我尝试在 prepareForSegue 中设置此变量的值时,为什么我的应用程序崩溃了?

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

我想要做的事情的要点是将我正在继续的窗口上的标签值设置为用户在前一个窗口中输入的文本。

用户通过单击“阅读”进行搜索,这将对他们进行搜索。

这是我的 prepareForSegue 方法:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
ReadingViewController *destination = segue.destinationViewController;

destination.textToRead = self.textInput.text;
}

textToRead 只是一个 NSString 对象,用于保存用户输入的文本。 (然后使用 viewDidLoad 方法将该文本设置为标签。)

被转入的窗口被设置为预期的不同 View Controller (ReadingViewController),我通过控制从“读取”UIButton 拖动到下一个窗口来创建转出。

我似乎无法弄清楚问题出在哪里。这是它给出的错误:

2013-03-13 19:00:08.119 Project Lego[1523:c07] -[UINavigationController setTextToRead:]: unrecognized selector sent to instance 0x894d230
2013-03-13 19:00:08.122 Project Lego[1523:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setTextToRead:]: unrecognized selector sent to instance 0x894d230'
*** First throw call stack:
(0x1c92012 0x10cfe7e 0x1d1d4bd 0x1c81bbc 0x1c8194e 0x2949 0x45bb87 0x45bc14 0x10e3705 0x172c0 0x17258 0xd8021 0xd857f 0xd76e8 0x46cef 0x46f02 0x24d4a 0x16698 0x1beddf9 0x1bedad0 0x1c07bf5 0x1c07962 0x1c38bb6 0x1c37f44 0x1c37e1b 0x1bec7e3 0x1bec668 0x13ffc 0x244d 0x2375 0x1)
libc++abi.dylib: terminate called throwing an exception
(lldb)

最佳答案

如果你想访问嵌入在导航VC中的 View Controller ,做这样的事情:

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{
UINavigationController *nav = (UINavigationController*)segue.destinationViewController;
ReadingViewController *destination = [nav.viewControllers objectAtIndex:0];
destination.textToRead = self.textInput.text;
}

关于ios - 当我尝试在 prepareForSegue 中设置此变量的值时,为什么我的应用程序崩溃了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15397351/

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