swift3 傳遞資料到下一頁的方法(一)-用button觸發segue

1.First in storyboard , select button to contact Second View Controller ,choose “present modally” ,then will gernate segue


2.in viecontroller ,use prepare method so whenever the segue is triggered ,will execute the prepare method


3.in prepare function ,sender value is from button ,so sender need to as! UIButton


4.1 how to set the Secondviewcontroller property?
first ->in Secondviewcontroller declare a property var name ,then set


4.2 why i need to gernate a property name and then set self.nameLabel.text = name ??

because when the Secondviewcontroller is present , its @IBOutlet nameLabel is nil like below


so i need to change the code into this below


5.run the app


Also published on Medium.


你的電子郵件位址並不會被公開。 必要欄位標記為 *