2017-09-04 49 views
0

我有兩個VC(的ViewControllerSettingsVCVC2)。在啓動時,打開指定的ViewController

我怎樣才能讓這個當你打開開關(位於SettingsVC)當應用程序啓動時,它會顯示VC2

默認值爲ViewController

+0

有任何閃屏控制器出現在你的應用程序? – CodeChanger

回答

0

寫代碼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; 
} 

設置isSwitchOnSettingsVC這樣的 -

UserDefaults.standard.set(true, forKey: "isSwitchOn") 
相關問題