![](/img/trans.png)
[英]How to open specific ViewController from TabBarController
[英]how to open my tabbarcontroller from scendelegate
我在標簽欄中有 2 個視圖控制器 controller 我正在嘗試打開第一個視圖控制器,從場景委托中顯示整個標簽欄
我有
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyBoard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
self.window?.rootViewController = viewController
self.window?.makeKeyAndVisible()
Main 是 storyboard,ViewController 是第一個 ViewController 的文件
有了這個,我看到了第一個視圖 controller,但我看不到標簽欄選項
提前致謝
為此,您需要實例化UITabBarController
- 而不是您的第一個視圖 controller。
在您的storyboard
中,為您的UITabBarController
提供一個標識符,就像您為ViewController
所做的一樣
這樣做之后,替換這一行:
let viewController
= storyBoard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
和
let viewController
= storyBoard.instantiateViewController(withIdentifier: "YourTabBarControllerIdentifier") as! UITabBarController
我相信這應該會按照您的預期工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.