LoginSignup
1
5

More than 5 years have passed since last update.

Swiftにおける画面遷移には、2つある

Posted at

初めに

この記事は、メモがわりです。ご了承ください。

画面遷移については、こちらを参考にしてください。
https://ja.stackoverflow.com/questions/17290/swift-segue%E3%81%AE%E7%A8%AE%E9%A1%9E%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6

通常の画面遷移の場合


self.present(SenddetailViewController, animated: true)

戻る場合は、


   @IBAction func tapCloseBtn(_ sender: Any) {
        self.dismiss(animated: true, completion: nil)
    }

navigation cotlollerの場合


 let SecondViewController = self.storyboard?.instantiateViewController(withIdentifier: "SecondVC") as! SecondViewController

            self.navigationController?.pushViewController(SecondViewController, animated: true)
            //遷移先のBox変数に、このコードないの変数Stringを代入する
            SecondViewController.Box = String

戻る場合は、


   @IBAction func tapCloseBtn(_ sender: Any) {
   self.navigationController?.popViewController(animated: true)
    }

この場合は、Storybordでどこへ遷移させるのかを遷移ものとのVIew(上のコードを書くview)の左上の丸印から
遷移先のviewの全体に対してControl で繋げる必要がある。

追記

NavbarやTabbarの先頭に戻りたいとき

segueを利用して戻る
performSegue()で利用する

といい。

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