34
31

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

StoryBoardのViewControllerをインスタンス化する

Last updated at Posted at 2015-06-29
swift

let mainVC = MainViewController()

上記の記載では、ストーリーボードで定義したボタンなどの配置まで紐付けることができないので、下記のようにストーリーボードをインスタンス化させる。

  1. Storyboard上で、ViewControllerを定義する
  1. Storyboard上で、ViewControllerのStoryboardIDを定義する
  1. 呼び出したいクラスで下記のコードを実行する
swift

var storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainVC = storyboard.instantiateViewControllerWithIdentifier("MainViewController") as! MainViewController
34
31
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
31

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?