2016-03-08 80 views
-1

我試圖執行另一個故事板到另一個UIViewController的一個過渡,但問題是,我想要的視圖來顯示我來自哪裏的觀點背後彈出背後的視圖。 我知道,因爲我的應用程序包括視圖之間的Snapchat般的導航,這樣我就可以拖動視圖向左或向右,我可以看到背後的看法。presentViewController()彈出最後一個視圖

這裏是我試圖做到這一點:

@IBAction func account(sender: UIButton) { 
    if self._isOnline { 
     self.pageController?.reverseViewControllerAnimated(true) 
    } 
    else { 
     let alertView = UIAlertController(title: "blablablabla", message: "blablablabla", preferredStyle: .Alert) 
     alertView.addAction(UIAlertAction(title: "No", style: .Cancel, handler: nil)) 
     alertView.addAction(UIAlertAction(title: "Yes", style: .Default, handler: { (alertAction) -> Void in 
      let storyboard = UIStoryboard(name: "SignUpLogin", bundle: NSBundle.mainBundle()) 
      let vc = storyboard.instantiateInitialViewController() as! UIViewController 
      self.presentViewController(vc, animated: false, completion: nil) 
     })) 
     presentViewController(alertView, animated: true, completion: nil) 
    } 
} 

隨着SignUpLogin這是我第二次.storyboard文件的名稱,在這裏我在Heart.storyboard。 的行動發生在一個UIAlertController,如果用戶按NO,沒有追加,如果他按是他應該被重定向到我SignUpLogin.storyboard文件的初始視圖。

O

我的問題來自於左下角的視圖。如果我在右上角的視圖中使用上面的代碼,那就行了!爲什麼?

我有沒有我該怎麼辦不同的想法。

+0

可以u顯示一些截圖來解釋你需要什麼? –

+0

從您發佈的代碼,沒有任何看起來錯誤。你能發佈更多的代碼或截圖嗎? – DookieMan

+0

請顯示您調用此代碼的完整方法。 – JAL

回答

0

我已經找到了解決我的問題!

@IBAction func account(sender: UIButton) { 
    if self._isOnline { 
     self.pageController?.reverseViewControllerAnimated(true) 
    } 
    else { 
     let alertView = UIAlertController(title: Constants.LocalizedJoinOurBand, message: Constants.LocalizedNeedToCreatAnAccount, preferredStyle: .Alert) 
     alertView.addAction(UIAlertAction(title: Constants.LocalizedNo, style: .Cancel, handler: nil)) 
     alertView.addAction(UIAlertAction(title: Constants.LocalizedYes, style: .Default, handler: { (alertAction) -> Void in 

      if let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate { 
       let storyboard = UIStoryboard(name: "SignUpLogin", bundle: NSBundle.mainBundle()) 
       let vc = storyboard.instantiateInitialViewController() as! UIViewController 
       UIApplication.sharedApplication().keyWindow?.rootViewController = vc 
      } 
     })) 
     presentViewController(alertView, animated: true, completion: nil) 
    } 
} 

我不知道爲什麼在這種情況下,特別是,但我有直接設置我的AppDelegate的rootViewController這一行:

UIApplication.sharedApplication().keyWindow?.rootViewController = vc 
相關問題