0
我有兩個VC(的ViewController,SettingsVC,VC2)。在啓動時,打開指定的ViewController
我怎樣才能讓這個當你打開開關(位於SettingsVC)當應用程序啓動時,它會顯示VC2?
默認值爲ViewController。
我有兩個VC(的ViewController,SettingsVC,VC2)。在啓動時,打開指定的ViewController
我怎樣才能讓這個當你打開開關(位於SettingsVC)當應用程序啓動時,它會顯示VC2?
默認值爲ViewController。
寫代碼didFinishLaunchingWithOptions
-
let isSwitchOn = UserDefaults.standard.bool(forKey: "isSwitchOn")
if isSwitchOn {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc2 = storyboard.instantiateViewController(withIdentifier: "Your identifier")
self.window!.rootViewController = vc2;
}
設置isSwitchOn
在SettingsVC
這樣的 -
UserDefaults.standard.set(true, forKey: "isSwitchOn")
有任何閃屏控制器出現在你的應用程序? – CodeChanger