答案 0 :(得分:0)
这是一个黑客。.但是我通过设置行值=网络回调上数组中的第一个元素来选择第一行。
if let row = self.form.rowBy(tag: "Row") as? PickerInlineRow<RowType> {
row.value = rowTypes.first
row.reload()
}
答案 1 :(得分:0)
假设您已创建数组或对象 让项目= [“ 1”,“ 2”,“ 3”,“ 4”,“ 5”,“ 6”]
<< PickerInlineRow<String>(){
row in
row.tag = "inlineRow"
row.options = items
row.title = "Tap to select"
row.displayValueFor = {
guard let teacherName = $0 else {return nil}
return teacherName.name
}
}.onChange({ (row) in
guard let value = row.value else {return}
print(value)
self.selectedTeacher = value
print("Selected teacher name :\(self.selectedTeacher.name) , ID : \(self.selectedTeacher.id)")
}).onCellSelection({ (cell, row) in
row.value = items.first
row.reload()
})
这里,当用户点击该行时会调用.onCellSelection,因此我们将从数组中获取第一个值并将其放入行中并重新加载行。