我在swift中使用XLForm并添加了一些" normal"像我这样的单元格和自定义单元格:
XLFormViewController.cellClassesForRowDescriptorTypes().setObject("MyCell", forKey: "MyCellType")
section = XLFormSectionDescriptor.formSectionWithTitle(NSLocalizedString("Section1Title", comment: "")) as! XLFormSectionDescriptor
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.Pair, rowType:"MyCellType", title: NSLocalizedString("Pair", comment: ""))
row!.cellConfigAtConfigure["titleLabel.text"] = "hello world"
row!.cellConfigAtConfigure["progressView.hidden"] = true
row!.action.formSelector = #selector(ChestbeltSettingsViewControllerImpl.didTouchButton(_:))
section!.addFormRow(row!)
然后我通过以下方式实施didTouchButton
:
func didTouchButton(sender: XLFormRowDescriptor) {
print("didTouchButton")
switch sender.tag {
case Tags.ShowHelp:
print("showHelp")
break
case Tags.Pair:
print("pair")
break
default: break
}
self.deselectFormRow(sender)
}
对于"正常" (不是自定义)单元格选择器工作正常,但对于我的自定义单元格甚至不会调用该方法。有人知道可能的原因吗?感谢
编辑:我通过让自定义单元格覆盖XLFormButtonCell
代替XLFormBaseCell