gpt4 book ai didi

ios - '-[UINavigationController setLanguage :]: unrecognized selector sent to instance 0x7f8fba7df4e0'

转载 作者:行者123 更新时间:2023-11-28 18:58:32 30 4
gpt4 key购买 nike

几个小时前,这段代码没有给我带来任何问题,但是,在更新我的 XCode 之后我的 XCode 并删除了第 3 方框架,它突然给了我上述异常。我非常困惑,因为我认为从那时到现在除了更新我的 XCode 之外没有任何变化可能导致问题。任何人都可以看到问题吗?

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

/*We check to make sure the segue corresponds to segue we created when a cell is selected*/
if ([[segue identifier] isEqualToString:@"show"]) {

/*Get a pointer to the selected row*/
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

/*Get a pointer to the ViewController we will segue to*/
ViewController *viewController = segue.destinationViewController;

/*Pass the dialect and code back to the ViewController*/
viewController.language = self.languages.allKeys[indexPath.row];
viewController.code = [self.languages objectForKey:viewController.language];

}
}

具体来说,以下两行导致了异常:

viewController.language = self.languages.allKeys[indexPath.row];
viewController.code = [self.languages objectForKey:viewController.language];

最佳答案

您的 segue 的目标 Controller 是 UINavigationController,您的 View Controller 可能是该导航 Controller 的顶层 View Controller 。你可能想要:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

/*We check to make sure the segue corresponds to segue we created when a cell is selected*/
if ([[segue identifier] isEqualToString:@"show"]) {

/*Get a pointer to the selected row*/
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

UINavigationController *navController = segue.destinationViewController

/*Get a pointer to the ViewController we will segue to*/
ViewController *viewController = navController.topViewController;

/*Pass the dialect and code back to the ViewController*/
viewController.language = self.languages.allKeys[indexPath.row];
viewController.code = [self.languages objectForKey:viewController.language];
}
}

关于ios - '-[UINavigationController setLanguage :]: unrecognized selector sent to instance 0x7f8fba7df4e0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28972189/

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