Я немного запутался в сценарии, я думаю, что моя логическая ошибка, пожалуйста, помогите мне решить ее, я действительно смущен. Сценарий является то, что:обновить ячейку в tableview также обновить другую ячейку
Существует вопросы в форме.
Каждый Вопрос Произошли ли ответ, первый является ДА, второй является NO, и третий является Не применимо.
- По умолчанию ДА.
- Если пользователь Нажмите на Да И Не применимо там не изменится в UI происходит, но если пользователь нажимает на NO там является TextField шоу в котором пользователь должен описать Разум NO ,
Теперь все это происходит. Но проблема возникает, когда пользователь нажимает кнопку НЕТ, когда отображается текстовое поле, но когда пользователь просматривает другую ячейку, отображается текстовое поле, и в этой ячейке также выбрано НЕТ, которое не выбрано пользователем. Я думаю, что его проблема с индексом или моей логикой, пожалуйста, помогите, я использую шаблон делегирования для событий кнопки.
смотрите вложения ниже
When User Select NO in Question No. 0
And Scroll Down than Question No. 6 is also shown as NO
Надежда ли один помочь мне, спасибо заранее
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "FormCell", for: indexPath) as! FormCell
cell.questionLbl.text = "Question No \(indexPath.row): What is Your Name"
cell.index = indexPath as NSIndexPath?
cell.delegate = self
cell.tag = indexPath.row
return cell
}
func yesBtnPressedAt(indexPath: NSIndexPath) {
print("YES")
let cell = self.tableView.cellForRow(at: indexPath as IndexPath) as! FormCell
if(cell.tag == indexPath.row){
self.tableView.beginUpdates()
cell.yesBtn.backgroundColor = ColorUtilities.selectedAnswerColor
cell.noBtn.backgroundColor = ColorUtilities.unSelectedAnswerColor
cell.notApplicableBtn.backgroundColor = ColorUtilities.unSelectedAnswerColor
cell.resonTextFiled.isHidden = true
cell.goToTeamBtn.isHidden = true
cell.heightForMaineView.constant = 89.0
cell.heightForTextField.constant = 0.0
self.tableView.endUpdates()
}
}
func noBtnPressedAt(indexPath: NSIndexPath) {
print("NO")
let cell = self.tableView.cellForRow(at: indexPath as IndexPath) as! FormCell
if(cell.tag == indexPath.row){
self.tableView.beginUpdates()
cell.yesBtn.backgroundColor = ColorUtilities.unSelectedAnswerColor
cell.noBtn.backgroundColor = ColorUtilities.selectedAnswerColor
cell.notApplicableBtn.backgroundColor = ColorUtilities.unSelectedAnswerColor
cell.resonTextFiled.isHidden = false
cell.goToTeamBtn.isHidden = false
cell.heightForMaineView.constant = 129.0
cell.heightForTextField.constant = 30.0
self.tableView.endUpdates()
}
}
func notApplicableBtnPressedAt(indexPath: NSIndexPath) {
print("Not Applicable")
let cell = self.tableView.cellForRow(at: indexPath as IndexPath) as! FormCell
if(cell.tag == indexPath.row){
self.tableView.beginUpdates()
cell.yesBtn.backgroundColor = ColorUtilities.unSelectedAnswerColor
cell.noBtn.backgroundColor = ColorUtilities.unSelectedAnswerColor
cell.notApplicableBtn.backgroundColor = ColorUtilities.selectedAnswerColor
cell.resonTextFiled.isHidden = true
cell.goToTeamBtn.isHidden = true
cell.heightForMaineView.constant = 89.0
cell.heightForTextField.constant = 0.0
self.tableView.endUpdates()
} }
Пожалуйста, включите код! Я мог бы помочь! – toiavalle
вы можете поделиться своим кодом? –
просмотрите его –