コードのみで遷移
modal遷移
let vc = self.storyboard?.instantiateViewController(withIdentifier: "toNext") as! NextViewController
self.present(vc, animated: true)
push遷移
let vc = self.storyboard?.instantiateViewController(withIdentifier: "toNext") as! NextViewController
self.navigationController?.pushViewController(vc, animated: true)
コードのみで異なるStoryboardに遷移
push遷移
let storyboard = UIStoryboard(name: "Storyboardのファイル名", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "ボードのID") as! ボードに紐づくViewController
self.navigationController?.pushViewController(vc, animated: true)
modal遷移
let storyboard = UIStoryboard(name: "Storyboardのファイル名", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "ボードのID") as! ボードに紐づくViewController
self.present(vc, animated: true)
コードで前の画面に戻る
modal遷移
dismiss(animated: true)
push遷移
一つ戻る
self.navigationController?.popViewController(animated: true)
一番最初に戻る
self.navigationController?.popToRootViewController(animated: true)