2017-09-04 45 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") 
相关问题