【发布时间】:2026-01-31 04:40:02
【问题描述】:
我有一个 RootVC。这是一个SwipeViewController: UINavigationController。
在WelcomeNavigationController 内,我正在检查一个条件。如果条件为真,我想打开 RootVC。
class WelcomeNavigationController: UINavigationController {
override func viewWillAppear(animated: Bool) {
backendless.userService.setStayLoggedIn(true)
if backendless.userService.currentUser != nil {
print("currentUser != nil")
dispatch_async(dispatch_get_main_queue()) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc : RootVC = storyboard.instantiateViewControllerWithIdentifier("RootVC") as! RootVC
appDelegate.window?.rootViewController = vc
appDelegate.window?.makeKeyAndVisible()
}
}
}
打印语句被执行,我的 RootVC 中的一些打印语句也被执行。所以理论上RootVC是加载的。但它是不可见的。如何使我的 RootVC 可见?
非常感谢您的帮助。
【问题讨论】: