【发布时间】:2020-05-19 20:44:04
【问题描述】:
当我存储了访问令牌后,我想导航到主页,但它不起作用。它总是在启动时将我引导到 LoginViewController。
目前我正在使用此代码:
AppDelegate.swift
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let accessToken: String? = KeychainWrapper.standard.string(forKey: "accessToken")
if accessToken != nil
{
let mainStoryboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let homePage = mainStoryboard.instantiateViewController(withIdentifier: "HomeViewController") as! HomeViewController
self.window?.rootViewController = homePage
}
return true
}
项目的用户界面:故事板
斯威夫特:5
Xcode:11.4
目标部署:13.4
【问题讨论】:
-
不,答案太旧了。
-
我在这里找到了解决方案:stackoverflow.com/questions/59563489/…