接觸swift 剛剛不久绳瘟,由于從android 開發(fā)轉(zhuǎn)到iOS易茬,于是第一件事就是如何進(jìn)行頁面之間進(jìn)行跳轉(zhuǎn)和傳值
跳轉(zhuǎn)方式:
1.storyboard中的segue 跳轉(zhuǎn)方式:
self.performSegueWithIdentifier("next",sender:self);
"next"為 ,segue中在sb中設(shè)置的Identifier 的id
傳值方式:
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
let dev=segue.destinationViewController as! NextViewController
//segue 在sb 中的傳值
dev.nexttext="pass"
}
2.普通的xib 界面的view controller 跳轉(zhuǎn)方式以及傳值方式
var nib=XibViewController()//需要跳轉(zhuǎn)的viewcontroller
self.presentViewController(nib, animated:true, completion: nil)
//傳值
nib.xibtest.text="連接超時(shí)"
3.關(guān)閉當(dāng)前的viewcontroller
self.dismissViewControllerAnimated(true, completion: nil)
4.也可以用protocol 來傳值茧妒。