2016-01-22 43 views
1

我需要根据用户的注册或不注册来设置我的应用的起始视图。 这将在AppDelegate中完成:在AppDelegate中切换查看(Swift)

 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的值没有故事板的成员”

任何结论呢?

+0

有您注册的故事板? –

+0

我如何注册我的故事板? – Dareyou

回答

0

样品:

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

当我这样做,我得到的错误:“Instants成员故事板不能用于类型AppDelegate” – Dareyou

+0

你得到了什么错误?解释更多.. –