2016-01-22 38 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

你得到了什麼錯誤?解釋更多.. –