0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Swift】UnwindSegueを使用して前の画面に戻る

Last updated at Posted at 2021-03-31

Unwind Segue

概要・使用シーン

・複数前のViewControllerの戻りたい時
・遷移時に何らかの処理(値を渡すなど)を行いたい時

実装方法

① FirstViewControllerにUnwindSegueの処理を書く
※遷移先で記述するのではなく遷移元 ← ここで少しハマりました‥笑
スクリーンショット 2021-03-31 23.53.02.png
② SecondViewController
(ア) Buttonをした時の処理を書く
32F913E6-BAF1-4F35-9A5F-31D9D6BDC337.jpeg
(イ)
(a) ViewControllerからControlキーを押しながらExitに接続。
(b) Identifierに①の処理で書いたもの記述
40D9D16A-9318-4539-A0A7-AE77A29C3531.jpeg

動作確認

・ビルドしてbuttonタップ後にtext("FirstVCに戻ります")が渡せていたら成功◎
スクリーンショット 2021-03-31 23.54.40.png
スクリーンショット 2021-03-31 23.54.52.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?