[swift4] コードで指定のControllerViewに遷移する方法

コードで指定のControllerViewに遷移する方法は以下の通り

let storyboard: UIStoryboard = self.storyboard!
let nextView = storyboard.instantiateViewController(withIdentifier: "[ViewContollerのID]")
present(nextView, animated: true, completion: nil)

 

異なるStoryBoardのViewConstollerの場合は以下の通り

let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let nextView = storyboard.instantiateInitialViewController()
present(nextView!, animated: true, completion: nil)

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です