您的位置:首页 > 移动开发 > Swift

Swift 闭包传值 反向传值

2017-03-07 16:35 1101 查看
RT

A界面 接收B界面返回的时候的值

A界面

        let vc = CZHourPicker()

        

        vc.backClosure = {(backStr: String) -> Void in

            self.durationBtn.setTitle(backStr, for: UIControlState.normal)

            self.durationBtnT.setTitle(backStr, for: UIControlState.normal)

        }

        

        self.present(vc, animated: true, completion: nil)

B界面

//定义闭包类型(特定的函数类型函数类型)

typealias InputClosureType = (String) -> Void

  //接收上个页面传过来的闭包块

    var backClosure: InputClosureType?

       self.backClosure!(resultStr)

       self.dismiss(animated: true, completion: nil)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: