VAAA VAAA - 4 months ago 123
Swift Question

Eureka - how to pass values to elements in custom row

I my swift projects using Eureka forms and I have a customer row:

This is my Xib:

enter image description here

This is my class:

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()

}
}


And this is how I add it to my form:

<<< CustomServiceRow();


I would like to know how can I pass values to set the name of the text of my button and the text of my label.

Any clue?

Answer

From Eureka's readme in Github:

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)
                }