1.簡単な方法
Buttonを次の場面にControl押しながらドラックアンドドロップする。
基本、showかPresentModallyを選ぶ。
2.コードで繋ぐ方法
条件つきで画面遷移したい時に使う。
Buttonではなう、ViewControllerの上の黄色丸から次画面にドラックアンドドロップ。
segueの四角をクリックして、Identifireに任意の名前をつける必要がある。
ButtonをActionでコードにつないで、遷移するための記述をする。
withIdentifier:にさっきつけた名前を入れる。
画面遷移するためのコード
performSegue(withIdentifier: “ここにID”, sender: nil)
@IBAction func plus(_ sender: Any) { count = count + 1 if count == 10 { //画面遷移をする performSegue(withIdentifier: "next", sender: nil) } }