在AppDelegate中切换视图(Swift)

时间:2016-01-22 14:16:33

标签: ios swift view appdelegate

我需要根据用户的注册情况设置我的应用的起始视图。 这将在AppDelegate中完成:

       func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
            if(isUserRegistrated() == true){
                let vc : AnyObject! = self.storyboard.instantiateViewControllerWithIdentifier("isRegistrated")
                    self.showViewController(vc as UIViewController, sender: vc)
            }
            else{
                let vc : AnyObject! = self.storyboard.instantiateViewControllerWithIdentifier("isNOTRegistrated")
                    self.showViewController(vc as UIViewController, sender: vc)
            }
       }

此时我收到了错误: " AppDelegate类型的值没有storyboard"

的成员

有任何结论吗?

1 个答案:

答案 0 :(得分:0)

示例:

let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("someViewController") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)