iOS swift 闭包(closure)作为属性

cell

    typealias closureBlock = (String)->Void;
    var postValueBlock:closureBlock?

vc

    cell.postValueBlock = {(btnText) in
        let story = UIStoryboard.init(name: "Main", bundle: nil)
        let VC:dailyReportVC = story.instantiateViewController(withIdentifier: "dailyReportVC") as! dailyReportVC;
        VC.showStr = btnText;
        VC.type = dailyReportEnum.dailyReport;
        VC.postValueBlock = {(str) in
            cell.valueBtn.setTitle(str, for: UIControlState.normal);
        }
        self.present(VC, animated: true, completion: nil);
    }

cell

    @IBAction func valueBtnClick(_ sender: Any) {
        postValueBlock!((valueBtn.titleLabel?.text)!);
    }
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页