gpt4 book ai didi

ios - 从应用程序委托(delegate)访问导航 Controller

转载 作者:行者123 更新时间:2023-11-28 09:00:54 28 4
gpt4 key购买 nike

我想从 appDelegate 访问一个嵌入了 UINavigation Controller 的 View Controller 。

我该怎么做,我知道我可以直接访问该 View Controller ,但在这种情况下导航栏不会出现,因此这不是我想要的。

我已经尝试了下面找到的代码,但它会提示警告并出现黑屏。

var storyboard1 = UIStoryboard(name: "Main", bundle: nil)
var viewController: ExamNav_ViewController = storyboard1.instantiateViewControllerWithIdentifier("ExamNav_ViewController") as! ExamNav_ViewController
var rootViewController = self.window!.rootViewController as! UINavigationController
// rootViewController.pushViewController(viewController, animated: true)
rootViewController.presentViewController(viewController, animated: true, completion: nil)

警告是:尝试在 UINavigationController 上呈现 PlayMyWay.ExamNav_ViewController:0x14fd19b50:0x14fd13a90 其 View 不在窗口层次结构中!

最佳答案

window = UIWindow(frame: UIScreen.mainScreen().bounds)
let navController: UINavigationController = UIStoryboard(name: "Main", bundle:nil).instantiateViewControllerWithIdentifier("provaNavController") as UINavigationController
window?.rootViewController = navController
window?.makeKeyAndVisible()

更多Click here to learn about that

关于ios - 从应用程序委托(delegate)访问导航 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32067836/

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