设为首页 加入收藏

TOP

iOS开发之OC与swift开发混编教程,代理的相互调用,block的实现。OC调用Swift中的代理, OC调用Swift中的Block 闭包(四)
2019-08-31 00:22:13 】 浏览:141
Tags:iOS 开发 swift 教程 代理 相互 调用 block 实现 Swift Block 闭包
tTextFieldDelegate:NSObjectProtocol {  
  •     func editTextField(_ str: String) -> Void  
  • }  
  •   
  • @objc(SecondViewController)  
  • class SecondViewController: UIViewController {  
  •   
  •     var editorDelegate:EditTextFieldDelegate?  
  •     var textField:UITextField?  
  •     var addButton:UIButton?  
  •     var pushButton:UIButton?  
  •       
  •     typealias editorBlock = (_ t:String) -> Void  
  •     var myEidtorBlock:editorBlock?  
  •       
  •     override func viewDidLoad() {  
  •         super.viewDidLoad()  
  •         self.view.backgroundColor = UIColor.white  
  •         textField = UITextField.init(frame: CGRect.init(x: 50, y: 60, width: 200, height: 50))  
  •         textField?.placeholder = "输入返回首页的内容"  
  •         self.view.addSubview(textField!)  
  •           
  •         addButton = UIButton.init(type: .custom)  
  •         addButton?.setTitleColor(UIColor.black, for: .normal)  
  •         addButton?.setTitle("pop", for: .normal)  
  •         addButton?.frame = CGRect.init(x: 50, y: 150, width: 200, height: 50)  
  •         addButton?.layer.borderColor = UIColor.black.cgColor  
  •         addButton?.layer.borderWidth = 1.0  
  •         addButton?.addTarget(self, action: #selector(popAction), for: .touchUpInside)  
  •         self.view.addSubview(addButton!)  
  •           
  •           
  •           
  •         pushButton = UIButton.init(type: .custom)  
  •         pushButton?.setTitleColor(UIColor.black
  • 首页 上一页 1 2 3 4 5 6 下一页 尾页 4/6/6
    】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
    上一篇完整代理的简单实现 下一篇【OC底层】KVO原理

    最新文章

    热门文章

    Hot 文章

    Python

    C 语言

    C++基础

    大数据基础

    linux编程基础

    C/C++面试题目