[英]How do I transition to a different view controllers present in different storyboards programmatically using swift?
let customerStoryboard = UIStoryboard(name: "Customer", bundle: nil) //First(Current) storyboard
let agentStoryboard = UIStoryboard(name: "Agent", bundle: nil) //Second storyboard
var otherVC = UIViewController! // ViewController reference
otherVC = agentStoryboard.instantiateViewControllerWithIdentifier("AgentProfile")
最后一個語句沒有執行或顯示結果,除此之外還需要做什么?
您只實例化視圖控制器。 要呈現它,您應該使用presentViewController方法
someVC.presentViewController(otherVC, animated: true, completion: nil)
使用此代碼顯示第二個視圖控制器。
let otherVC : AnyObject! = self.agentStoryboard.instantiateViewControllerWithIdentifier("AgentProfile")
self.showViewController(otherVC as UIViewController, sender: otherVC)
let secondViewController = self.storyboard.instantiateViewControllerWithIdentifier("SecondViewController") as SecondViewController
self.navigationController.pushViewController(secondViewController, animated: true)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.