
//委托
import UIKit
protocol ValuePassDelegaete:NSObjectProtocol{
func passValue(value:String)
}
class VIEwController2: UIVIEwController {
var delegate:ValuePassDelegaete?
@IBOutlet weak var valuelab: UILabel!
@IBAction func Back(sender: UIbutton) {
self.delegate!.passValue("123")
}
overrIDe func vIEwDIDLoad() {
super.vIEwDIDLoad()
// Do any additional setup after loading the vIEw.
}
overrIDe func dIDReceiveMemoryWarning() {
super.dIDReceiveMemoryWarning()
// dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// 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.
}
*/
}
//代理
import UIKit
class VIEwController1: UIVIEwController,ValuePassDelegaete {
@IBOutlet weak var valueLab: UILabel!
@IBAction func Click(sender: UIbutton) {
let vIEw2 = VIEwController2(nibname:"VIEwController2",bundle:nil)
vIEw2.delegate = self
self.navigationController?.pushVIEwController(vIEw2,animated: true)
}
func passValue(value: String) {
self.valueLab.text = value
}
overrIDe func vIEwDIDLoad() {
super.vIEwDIDLoad()
// Do any additional setup after loading the vIEw.
}
overrIDe func dIDReceiveMemoryWarning() {
*/
}
总结以上是内存溢出为你收集整理的swift代理传值的实现全部内容,希望文章能够帮你解决swift代理传值的实现所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)