LoginSignup
0
1

More than 5 years have passed since last update.

Swift 3.0 で 別なviewcontrollerとstoryboardに遷移する方法

Posted at

別なviewcontrollerとstoryboardに遷移するには

1.まずはXCode上に新しいStoryboardとViewControllerを作っておく
Screen Shot 2017-06-23 at 3.21.58 PM.png

*Storyboard2.storyboard と ViewController2.swiftと名付けておく

2.適当にViewController.swiftにボタンを作ってアクションを加える。

3.アクション内にコードを追加!

    @IBAction func to2ndStoryBoard(_ sender: Any) {
        let storyboard: UIStoryboard = UIStoryboard(name: "Storyboard2", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "NextViewController") as! ViewController2
        self.show(vc, sender: self)
    }

4.結果

見た目はただのNavigationViewControllerですが、プロジェクトが大きくなる時にstoryboardを分けられると便利。

jumptoanotherStoryboard.gif

0
1
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
0
1