我對 Swift 和 Xcode 還很陌生,我在網上找不到答案,所以我希望你們能幫助我。
我正在嘗試在有人登錄時更改螢屏。我正在嘗試將默認入口點更改為另一個螢屏,但不知何故它不起作用。
這是AppDelegate我試圖更改入口點的地方:
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let mainStoryboard = UIStoryboard(name: "Main" , bundle: nil)
let initialViewController = mainStoryboard.instantiateViewController(withIdentifier: "homePage") as! HomePageController
window?.rootViewController = initialViewController
window?.makeKeyAndVisible()
return true
}
在這里,我已經為我想用默認入口點替換的螢屏/控制器設定了 ID(默認入口點是我的登錄螢屏)。

uj5u.com熱心網友回復:
嘗試在 sceneDelegate 中這樣做:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowsScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowsScene)
window?.makeKeyAndVisible()
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = mainStoryboard.instantiateViewController(withIdentifier: "homePage") as! HomePageController
window?.rootViewController = initialViewController
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/532908.html
標籤:IOS迅速故事板
