gpt4 book ai didi

ios - popToViewController 后 pushViewController 上的应用程序崩溃

转载 作者:行者123 更新时间:2023-11-28 21:04:19 25 4
gpt4 key购买 nike

我试图搜索这个,但找不到任何完美的解决方案。我的应用程序有自定义动画 View 和两个侧抽屉。我也有自定义导航 Controller ,它有滑动顶栏。从 appDelegate 我将第一个 Controller 设置为 rootViewController,然后推送 ViewController(即带有动画的 mainViewController)。然后试图插入第二个 Controller 。在单击按钮时,我可以从第二个 Controller 转到第三个 Controller 或 rootViewController。当我使用 popToViewController 从 secondController 返回后尝试转到第二个 viewController 时,应用程序崩溃了。

我将 appdelegate 的 rootViewController 设置为:

let profileViewController = mainStoryboard.instantiateViewController(withIdentifier: "LoadingDataView") as! LoadingDataView
self.navigationController = SDNavigationController(rootViewController: profileViewController);
self.navigationController.navigationBar.isHidden=true;
self.window!.rootViewController = self.navigationController
self.window!.makeKeyAndVisible()

将 ViewController(mainController) 推送为:

if( app.navigationController.viewControllers.count < 2){
let profileViewController=mainStoryboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
app.navigationController?.pushViewController(profileViewController, animated: true);
}else{
let profileViewController=mainStoryboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
app.navigationController?.pushViewController(profileViewController, animated: false);
let emptyView = UIViewController();
app.navigationController?.pushViewController(emptyView, animated: false);
app.navigationController.popViewController(animated: true);
}

然后将第二个 viewController 推送为:

let tutorialView=myStory.instantiateViewController(withIdentifier: "BookmarksDetails") as! BookmarksDetails;
self.navigationController!.pushViewController(tutorialView, animated: true);

从第二个 viewController 返回:

let testController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ViewController") as! ViewController
let appDelegate = UIApplication.shared.delegate as! AppDelegate
testController.isOpenLeftDrawer = true
appDelegate.window?.rootViewController = testController
self.navigationController?.popToRootViewController(animated: true)

当我尝试从 viewController(mainController) 转到 secondViewController 时,应用程序崩溃了。

最佳答案

为什么要这样做-

app.navigationController.popViewController(animated: true);

这里只是push,不要使用pop ViewController代码。

关于ios - popToViewController 后 pushViewController 上的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46558513/

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