画面遷移(別のstoryboardを追加して遷移)

2020/09/26確認

 

command + 1 して、フォルダを右クリックして、New File...を選択して、storyで検索して、

Storyboardを追加します。名前をSub.storyboardにします。

f:id:fedora9:20200926113626p:plain

f:id:fedora9:20200926113816p:plain

command + 1 して、Sub.storyboardを開き、+をクリックして、ViewControllerを追加して、ラベルを追加します。

f:id:fedora9:20200926120412p:plain

command + 1 して、フォルダを右クリックして、New File...を選択して、Cocoa Touch Classを選択して、ViewControllerを追加します。SubViewControllerにします。

f:id:fedora9:20200926114010p:plain

command + 1 して、Sub.storyboardを選択して、一番左のボタンを選択して、Custom Class - ClassにSubViewContollerを設定し、Identity - StoryboarIDにSubViewを設定し、Use Storyboard IDにチェックします。

f:id:fedora9:20200926120554p:plain

遷移元のボタンをTapした時の処理を追加します。

    let storyboard = UIStoryboard(name: "Sub", bundle: nil)

    let next = storyboard.instantiateViewController(withIdentifier: "SubView")

    self.present(next, animated: true)

 

iPhone開発での画面遷移方法まとめ(Swift) - Qiita