明日も楽をするために

めんどくさがりなITエンジニアが書くメモ帳

StoryBoardでEmbed inで追加したNavigationControllerをModalViewで開く場合の値の渡し方

StoryBoardでEmbed inで追加したViewControllerにModalViewで開いて値を渡す方法

FirstViewController

NavigationController(SecondViewControllerにEmbed inで追加したもの)

SecondViewController

let modalView = storyboard!.instantiateViewControllerWithIdentifier("NavigationController") as! UINavigationController
modalView.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
let secondView = modalView.visibleViewController as! SecondViewController
secondView.foo = foo//値を送る
self.presentViewController(secondView, animated: true, completion: nil)