Eureka - 如何将值传递给自定义行中的元素

时间:2016-07-13 21:30:47

标签: swift eureka-forms

我使用Eureka表格的快速项目,我有一个客户行:

这是我的Xib:

repl.it

这是我的班级:

public class CustomServiceCell : Cell<Bool>, CellType{

    @IBOutlet weak var btnDelete: UIButton!
    @IBOutlet weak var lblTitle: UILabel!


    public override func setup() {
        //height = { 60 }
        //lblTitle.text = row.title
        super.setup()
        selectionStyle = .None
        //btnDelete.addTarget(self, action: #selector(onDelete), forControlEvents: .TouchUpInside)

    }

    @IBAction func onDelete(sender: UIButton) {
        print("Delete Button tapped")
        row.value = true

    }

    public override func update() {
        super.update()

    }
}

这就是我将它添加到表单的方式:

<<< CustomServiceRow();

我想知道如何传递值来设置按钮文本的名称和标签的文本。

有任何线索吗?

1 个答案:

答案 0 :(得分:0)

来自Github的Eureka's readme

let row  = SwitchRow("SwitchRow") { row in      // initializer
                        row.title = "The title"
                    }.onChange { row in
                        row.title = (row.value ?? false) ? "The title expands when on" : "The title"
                        row.updateCell()
                    }.cellSetup { cell, row in
                        cell.backgroundColor = .lightGrayColor()
                    }.cellUpdate { cell, row in
                        cell.textLabel?.font = .italicSystemFontOfSize(18.0)
                }