Sitemap
Astrid

Astrid

A Swift learner.

unwindSegue

Aug 6, 2021
Press enter or click to view image in full size

unwindSegue就是把segue倒轉,但不是在原本的segue上,而是要用程式碼新創一條segue。

大致來說有以下幾個步驟:

Step1: 新創segue。

Step2:選定要用新創segue。

Step3:將新創segue的segue identifier取名。

Step4:執行perform segue。

Get Astrid’s stories in your inbox

Join Medium for free to get updates from this writer.

Step1: 在code檔案中撰寫新創segue的method。

@IBAction func goBack(unwindSegue:UIStoryboardSegue){}

***注意:假設要從第二頁回到第一頁的話,此method要寫在第一頁。

Press enter or click to view image in full size
Step1: 新創segue。

Step2:在Document Outline拉線,選定要用Step1寫的method。

Press enter or click to view image in full size
Step2:選定要用新創segue。

Step3:點選storyBoard左側列表的method,將segue identifier取名。

Press enter or click to view image in full size
Step3:將新創segue的segue identifier取名。

Step4:將view上的button從storyBoard連線到第二頁程式碼區,執行perform segue。

Press enter or click to view image in full size
Step4:執行perform segue。

--

--