После поиска я не смог найти решение, которое бы сработало для меня. У меня есть несколько текстовых полей в ячейке таблицы. То, что я пытаюсь сделать, это изменить эти поля со скрытых на видимые с помощью начального стирания.
Код для cellForRowAt
:
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as UITableViewCell
let newCategory = cell.viewWithTag(5) as! UITextField
let newAmount = cell.viewWithTag(6) as! UITextField
newCategory.isHidden = true
newAmount.isHidden = true
return cell
}
Код для ведущихSwipe:
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let indexPath = IndexPath(row: 0, section: 0)
let cell = tableView.cellForRow(at: indexPath)
let contextItem = UIContextualAction(style: .normal, title: "Edit") { (contextualAction, view, boolValue) in
cell.newCategory.isHidden = false
cell.newAmount.isHidden = false
boolValue(false)
}
let swipeActions = UISwipeActionsConfiguration(actions: [contextItem])
return swipeActions
}
Я получаю сообщение об ошибке "Значение типа 'UITableViewCell?' не имеет члена 'newCategory' "и подобных для newAmount.