gpt4 book ai didi

ios - 初始化 Root View Controller 导致崩溃

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

我使用下面的代码来初始化一个 Root View Controller

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

{

[window addSubview:rootViewController.view];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController: rootViewController ];
}

在ios 4上用了大约2年,ios5上用了1年,开始运行app没问题但在 ios6 上它崩溃并报告

* 由于未捕获的异常“UIViewControllerHierarchyInconsistency”而终止应用程序,原因:“将 Root View Controller 添加为 View Controller 的 subview :”

欢迎任何评论

最佳答案

'rootViewController' 已经在您的 View 层次结构中。首先将它从 (window.rootViewController ?) 中的任何其他容器中删除 (window.rootViewController = nil)。

关于ios - 初始化 Root View Controller 导致崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12620409/

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