【发布时间】:2019-07-27 11:11:08
【问题描述】:
我有两个故事板,一个包含应用程序的所有内容,另一个包含我的应用程序的“入门”/教程。
教程完成后,我想导航回我原来的视图控制器。
这是我导航到另一个故事板的代码:
let defaults = UserDefaults.standard
if defaults.bool(forKey: "firstOpened") {
print("First VC launched")
}else{
var vc: UIViewController
let goTo = UIStoryboard(name: "Onboarding", bundle: nil).instantiateViewController(withIdentifier: "notificationStoryboard") as! FirstOnboardingViewController
self.present(goTo, animated: true, completion: nil)
}
有了这个,它就可以工作了,除了 TabBarController 没有显示,也没有按照我想要的方式工作。
这是我导航回 Main.Storyboard 的代码:
@objc func handleSecondPush() {
//registerForRemoteNotifications()
UserDefaults.standard.set(true, forKey: "firstOpened")
let goTo = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "pushToFeedVC")
self.present(goTo, animated: true, completion: nil)
//self.performSegue(withIdentifier: "goToLink", sender: nil)
}
我也在其他 Storyboard 中尝试过,但使用此按钮不会改变视图:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "MainTabBarController") as! UITabBarController
print(controller)
self.window?.rootViewController = controller
self.window?.makeKeyAndVisible()
if let tabBarVc = self.window?.rootViewController as? UITabBarController {
tabBarVc.selectedIndex = 1
}
简短的问题:所以我的问题是,如何从不包含导航控制器还是 TabBarController?
【问题讨论】:
标签: swift xcode firebase uiviewcontroller uistoryboard