在我的故事板中,我没有像initialViewController 那样的视图,但我有故事板,我想选择那取决于是否记录,例如。
我有AppDelegate
func application(application: UIApplication, didFinishLaunchingWithOptions: [NSObject: AnyObject]?) -> Bool
{
let storyboard = UISToryboard(name: "Main", bundle: nil)
if isLogged{
//Access to DatesViewController
let vc = storyboard.instantiateViewControllerWithIdentifier("dates")
self.window?.rootViewController?.presentViewController(vc, animated:true,completion: nil)
}else{
//Access to LoginViewController
let vc = storyboard.instantiateViewControllerWithIdentifier("login")
self.window?.rootViewController?.presentViewController(vc, animated:true,completion: nil)
}
self.window?.makeLeyAndVisible()
return true
我不知道如何做到这一点,有很多关于objetiveC的信息,但对于Swift没有。
这不起作用,错误是:*
无法为UIMainStoryBoardFile“Main”实例化默认视图控制器 - 或者未设置指定的入口点?
*
如果你能帮助我,请谢谢!
这项工作:
func application(application: UIApplication, didFinishLaunchingWithOptions: [NSObject: AnyObject]?) -> Bool
{
let storyboard = UISToryboard(name: "Main", bundle: nil)
if isLogged{
//Access to DatesViewController
var vc = self.window?.rootViewController?.storyboard?.instantiateViewControllerWithIdentifier("dates")
self.window?.rootViewController = vc
}else{
//Access to LoginViewController
var vc = self.window?.rootViewController?.storyboard?.instantiateViewControllerWithIdentifier("login")
self.window?.rootViewController = vc
}
self.window?.makeLeyAndVisible()
return true