alerts-and-pickers
alerts-and-pickers copied to clipboard
能否让 pickerView 在初始化时支持多组个选中?
目前只能选择一组:
init(values: Values, initialSelection: Index? = nil, action: Action?)
支持多组选中,这样做可行吗?:
init(values: Values, initialRows: [Int]? = nil, action: Action?)
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
if var initialRows = initialRows {
// 截取超出的部分
if initialRows.count > values.count {
initialRows = Array(initialRows[0..<values.count])
}
initialRows.enumerated().forEach { (column, row) in
if values[column].count > row {
pickerView.selectRow(row, inComponent: column, animated: true)
}
}
}
}
能否添加这样的功能?
@hjzCy Please, translate into english!
@dillidon In other words, let the pickerView be able to select more than one.