gpt4 book ai didi

ios - segue 不工作导致应用程序崩溃

转载 作者:行者123 更新时间:2023-11-28 20:02:12 25 4
gpt4 key购买 nike

我的代码中断了。起初 segue 是模态的,我试图将其更改为推送但它仍然无法正常工作我的代码如下:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
if ([[segue identifier ] isEqualToString:@"detailLoanSeg"]){
detailLoan *theController=[segue destinationViewController];
theController.time=_time;
theController.cuurLoan=_cuurLoan;
theController.currName=_currName;
}
}

xcode 中的错误是:

 014-05-07 04:38:11.257 LoanCalc[1561:a0b] -[UIViewController setTime:]: 
unrecognized selector sent to instance 0xa05f1f0
2014-05-07 04:38:11.266 LoanCalc[1561:a0b] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[UIViewController setTime:]:
unrecognized selector sent to instance 0xa05f1f0'

最佳答案

看起来,在 Storyboard中,您忘记指明目标 View Controller 的自定义类。在 Storyboard中,选择目标 VC,单击右侧的第三个检查器并将其自定义类设置为“detailLoan”(这违反了类命名约定)。

错误是你的目标 vc 是一个通用的 UIViewController,它自然不会实现 setTime: 方法。

关于ios - segue 不工作导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23507373/

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