gpt4 book ai didi

ios - 从 UITabBarController 和 UINavigationController 访问 UIViewController

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

我正在开发一个基于 UITabbar 和 View 层次结构的应用程序,如下所示。

UITabBarController ----> UINavigationController ----> UIViewController

我有将打开特定 UIViewController 的推送通知负载,我可以使用 View Controller Storyboard ID 直接显式打开 UIViewController,但不会显示 tabBar 和 Navbar。我怎样才能转到特定的 View Controller 并显示来自 AppDelegate didReceiveRemoteNotifications 的 TabBar 和 NavController。

谢谢!

最佳答案

你必须实例化你所有的 VC 并将它们全部设置为他的前任的根:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

let mainStoryboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let yourVC = mainStoryboard.instantiateViewControllerWithIdentifier("YourVC_Identifier");
let yourNavController = mainStoryboard.instantiateViewControllerWithIdentifier("YourNAV_Identifier") as! UINavigationController
let yourTabController = mainStoryboard.instantiateViewControllerWithIdentifier("YourTAB_Identifier") as! UITabBarController

yourNavController.setViewControllers([yourVC], animated: false)
yourTabController.setViewControllers([yourNavController], animated: false)


self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.rootViewController = yourTabController
self.window?.makeKeyAndVisible()



return true
}

关于ios - 从 UITabBarController 和 UINavigationController 访问 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41123523/

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