My question about picker view. I have two textfield and these are connect picker view but when I try to make selection these two textfields text become same. I already try make tag for picker view but it didn't work. Here my code for better understand.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 3 {
let cell = tableView.dequeueReusableCell(withIdentifier: "TextFieldCellTeslim", for: indexPath) as! TextFieldCellTeslim
let datePickerTeslim = UIPickerView()
datePickerTeslim.delegate = self
datePickerTeslim.dataSource = self
datePickerTeslim.backgroundColor = .white
cell.dateTextFieldTeslim.inputView = datePickerTeslim
datePickerTeslim.tag = indexPath.row
return cell
}
if indexPath.section == 2 {
let cell = tableView.dequeueReusableCell(withIdentifier: "TextFieldCell", for: indexPath) as! TextFieldCell
let datePicker = UIPickerView()
datePicker.delegate = self
datePicker.dataSource = self
datePicker.backgroundColor = .white
cell.dateTextField.inputView = datePicker
datePicker.tag = indexPath.row
return cell
}
These code show us connection of picker view.
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if component == 0 {
secilenTarih = tarihArray[row]
let path = IndexPath.init(row: pickerView.tag, section: 2)
let cell = tableView.cellForRow(at: path) as? TextFieldCell
cell!.dateTextField.text = secilenTarih
let pathTeslim = IndexPath.init(row: pickerView.tag, section: 3)
let cellTeslim = tableView.cellForRow(at: pathTeslim) as? TextFieldCellTeslim
cellTeslim!.dateTextFieldTeslim.text = secilenTarih
}
if component == 1 {
secilenSaat = saatArray[row]
let path = IndexPath.init(row: pickerView.tag, section: 2)
let cell = tableView.cellForRow(at: path) as? TextFieldCell
cell!.dateTextField.text = secilenTarih + " " + secilenSaat
let pathTeslim = IndexPath.init(row: pickerView.tag, section: 3)
let cellTeslim = tableView.cellForRow(at: pathTeslim) as? TextFieldCellTeslim
cellTeslim!.dateTextFieldTeslim.text = secilenTarih + " " + secilenSaat
}
}
And here my picker view extension. I want to make separate selectable of these two textfield.How can I make it? I hope I asked clearly.