我正在尝试创建一个显示图像的自定义行。因此,我首先尝试了 Eureka 页面中指示的基本自定义行:https ://github.com/xmartlabs/Eureka#basic-custom-rows
这是我正在使用的代码:
import Eureka
public class CustomCell2: Cell<Bool>, CellType{
@IBOutlet weak var switchControl: UISwitch!
@IBOutlet weak var label: UILabel!
public override func setup() {
super.setup()
switchControl.addTarget(self, action: #selector(CustomCell2.switchValueChanged), forControlEvents: .ValueChanged)
}
func switchValueChanged(){
row.value = switchControl.on
row.updateCell() // Re-draws the cell which calls 'update' bellow
}
public override func update() {
super.update()
backgroundColor = (row.value ?? false) ? .whiteColor() : .blackColor()
}
}
public final class CustomRow: Row<Bool, CustomCell2>, RowType {
required public init(tag: String?) {
super.init(tag: tag)
// We set the cellProvider to load the .xib corresponding to our cell
cellProvider = CellProvider<CustomCell2>(nibName: "CustomCell2")
}
}
并将其保存为 CustomCell2.swift。我正在使用以下方法调用该自定义行:futurSection <<< CustomRow ("")
但我收到一个错误:Could not load NIB in bundle with name 'CustomCell2'
而且,如何将其更改为 UIImage?