是否可以转换MultipleSelectorRow
的选项?我想将每个选项转换为$0.capitalized
。我首先尝试$0.displayValueFor
,但它看起来像表格中显示的值?阅读问题,我能够做到这一点:
.onPresent { _, to in
to.sectionKeyForValue = { $0.capitalized }
}
将添加部分。是否有任何属性允许我将选项映射到显示值?
答案 0 :(得分:0)
尝试使用此代码
<<< MultipleSelectorRow<String>() {
$0.options = ["prueba","prueba","prueba3"]
$0.tag = "gradeType"
$0.title = "Grade Types"
$0.selectorTitle = "Pick the posted grade types"
//$0.value = prevGradeTypeList
//$0.options = gradeTypePicker
}.cellSetup({ (pushSelectorCell, row) in
row.options = row.options.map({$0.capitalized})
})
希望这有助于你
答案 1 :(得分:0)
这也可能有效:
.onPresent { _, to in
to.selectableRowCellUpdate = { cell, row in
if let title = row.selectableValue?.capitalized {
cell.textLabel?.text = title
}
}
答案 2 :(得分:0)
使用 CustomStringConvertible
扩展用于选项的类型并覆盖 description
属性。
public enum MySelectorType: String, CaseIterable, CustomStringConvertible {
case one
case two
case three
case four
public var description: String {
return rawValue.localizedCapitalized
}
}
let myRow = MultipleSelectorRow<MySelectorType> { row in
row.title = RLOC.edit_device_startup_on_off()
row.options = MySelectorType.allCases
}