Как сделать отдельный вид выбора в одном контроллере вида? - PullRequest
0 голосов
/ 08 октября 2019

Мой вопрос о представлении выбора. У меня есть два текстовых поля, и это представление выбора подключения, но когда я пытаюсь сделать выбор, эти два текстовых поля становятся одинаковыми. Я уже пробовал сделать тег для просмотра выбора, но это не сработало. Здесь мой код для лучшего понимания.

    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
    }

Этот код показывает нам соединение вида выбора.

    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

    }
}

А вот мое расширение просмотра выбора. Я хочу сделать отдельный выбор из этих двух текстовых полей. Как я могу сделать это? Я надеюсь, что я спросил ясно.

...