swift3 傳遞資料到下一頁的方法(二)-以取得下一頁storyboard Id的方式

  1. First generate SecondViewController.swift ,then set the storyboard id = next

2.set two button function = goNext

3.in SecondViewController generate a property name , then set self.namelabel.text = name

4. the whole code is below, then we analysis the code step by step like below (4.1,4.2,4.3)

4.1 In goNext function ,first use self.storyboard?.instantiateViewController(withIdentifier: “next”) to obtain the controller but need to tranform to SecondViewController

4.2 because we know the sender is UIButton , so it can set controller.name = sender.currentTitle

4.3 finally we need to present the controller ,then it will show

5. run the app


Originally published at swifthao的ios學習紀錄blog.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.