在尤里卡的自定义行

我正在尝试创build一个显示图像的自定义行。 所以我开始尝试在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?

你好,我一直在审查你的问题,这是我的结果

我使用你的代码,并做了一些修改,这是我的EurekaCustomImageCell.swift

 import UIKit import Eureka public class CustomCell2: Cell<Bool>, CellType{ @IBOutlet weak var customImage: UIImageView! public override func setup() { super.setup() } 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") } } 

你可以看到这里是一个@IBOutlet weak var customImage: UIImageView! 这是在我的xib文件中为这个自定义单元格定义的sockets,请检查此图像

在这里输入图像说明

我希望这可以帮助你,这对我没有任何问题