gpt4 book ai didi

ios - ios8、popToViewController 和 UIViewControllerHierarchyInconsistency 崩溃

转载 作者:行者123 更新时间:2023-12-02 04:27:36 27 4
gpt4 key购买 nike

iOS7、Xcode 和 5 一切都很好 - 升级到 Xcode 6 和 iOS8 后,应用程序突然崩溃,而它一直工作正常。

崩溃时显示的错误是:

Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'adding a root view controller as a child of view controller:'

我设法找到了造成问题的单行:

[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:4] animated:YES];

该应用程序在练习时最多可添加 8 个 View ;当练习完成后,只需返回到最后一个 View ,即练习的菜单,因此 4。有点硬编码,但简单高效,因为总是如此。

我不知道 popToViewController 正在这样做。

任何帮助或想法将不胜感激。

最佳答案

我终于找到了一个有效的解决方案 - 所以这里是完成/记录之前:

UINavigationController* savedUinvc = self.navigationController;
UIViewController *one = nil;
one = [savedUinvc popViewControllerAnimated:NO];
UIViewController *two = nil;
two = [savedUinvc popViewControllerAnimated:NO];
UIViewController *three = nil;
three = [savedUinvc popViewControllerAnimated:YES];

关于ios - ios8、popToViewController 和 UIViewControllerHierarchyInconsistency 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25832977/

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