swift代理传值的实现

swift代理传值的实现,第1张

概述//委托 import UIKit protocol ValuePassDelegaete:NSObjectProtocol{          func passValue(value:String) } class ViewController2: UIViewController {               var delegate:ValuePassDelegaete?     @IB

//委托

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代理传值的实现所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1088012.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存