gpt4 book ai didi

ios - 查看 Controller 在创建 segue 时出错

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

我有一个导航 Controller ,第一个 VC 模式进入第二个很好。我按下 ctrl+button 并将其拖过,一切正常。

我正在(再次)从第一个 VC 进行第二次 segue,这次是另一个按钮,我是 ctrl+button 并将其拖到新的 VC,我在 XCODE 中遇到了一个 USELESS 错误-

2014-03-04 11:57:21.340 OutTonight[3173:60b] -[SettingsViewController setDealdetail:]: unrecognized selector sent to instance 0x16e686d0 2014-03-04 11:57:21.342 OutTonight[3173:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SettingsViewController setDealdetail:]: unrecognized selector sent to instance 0x16e686d0' * First throw call stack:

这是我的prepareforsegue代码

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = [self.tableview indexPathForSelectedRow];
DealViewController *detailView = (DealViewController *)segue.destinationViewController;
detailView.dealdetail = [self.allcontent objectAtIndex:indexPath.row];
detailView.dealpostcode = [self.allpostode objectAtIndex:indexPath.row];
detailView.dealvenuename = [self.allname objectAtIndex:indexPath.row];
detailView.dealaddress = [self.alladdress objectAtIndex:indexPath.row];
detailView.dealaddress2 = [self.alladdress2 objectAtIndex:indexPath.row];
detailView.deallat = [self.alllat objectAtIndex:indexPath.row];
detailView.deallng = [self.alllong objectAtIndex:indexPath.row];
detailView.userlatitude = [[NSUserDefaults standardUserDefaults] objectForKey:@"UserLatitude"];
detailView.userlongitude = [[NSUserDefaults standardUserDefaults] objectForKey:@"UserLongitude"];
}

有什么想法吗? enter image description here

最佳答案

我假设您已经在 -prepareForSegue: 中为原始转场做了一些事情?在这种情况下,您需要确保在 -prepareForSegue: 中检查它是哪个转场,并为每个转场做正确的事情。

编辑:

为了扩展我的答案,我猜您正在使用 segue.destinationViewController,并对其调用 setDealdetail: 。这可能适用于您的初始转场,因为 destinationViewController 响应了该消息,但是新转场的目的地没有。您需要检查正在执行哪个segue。使用 [segue.identifier isEqualToString:MySegueIdentifierString];

编辑 2(发布代码后):

好的,您需要检查 -prepareForSegue: 中正在执行哪个 Segue。像这样:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:SegueToDealViewControllerIdentifier]) {
NSIndexPath *indexPath = [self.tableview indexPathForSelectedRow];
DealViewController *detailView = (DealViewController *)segue.destinationViewController;
detailView.dealdetail = [self.allcontent objectAtIndex:indexPath.row];
detailView.dealpostcode = [self.allpostode objectAtIndex:indexPath.row];
detailView.dealvenuename = [self.allname objectAtIndex:indexPath.row];
detailView.dealaddress = [self.alladdress objectAtIndex:indexPath.row];
detailView.dealaddress2 = [self.alladdress2 objectAtIndex:indexPath.row];
detailView.deallat = [self.alllat objectAtIndex:indexPath.row];
detailView.deallng = [self.alllong objectAtIndex:indexPath.row];
detailView.userlatitude = [[NSUserDefaults standardUserDefaults] objectForKey:@"UserLatitude"];
detailView.userlongitude = [[NSUserDefaults standardUserDefaults] objectForKey:@"UserLongitude"];
}
}

其中SegueToDealViewControllerIdentifier是原始segue的segue标识符。

关于ios - 查看 Controller 在创建 segue 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22171658/

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