dillidon / alerts-and-pickers

Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...
MIT License
5.66k stars 703 forks source link

能否让 pickerView 在初始化时支持多组个选中? #66

Open baagod opened 5 years ago

baagod commented 5 years ago

目前只能选择一组:

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)
            }
        }
    }
}

能否添加这样的功能?

dillidon commented 5 years ago

@hjzCy Please, translate into english!

baagod commented 5 years ago

@dillidon In other words, let the pickerView be able to select more than one.