0

Мне нужно поработать с элементами коллекции. Но проблема в том, что после того как я возвращаю свою ячейку, я могу взять с нее все данные, но не могу ничего изменить, вплоть до того, что метод

newCell.textField.becomeFirstResponder()

не вызывается. Если я правильно понял Swift, то мы больше не обращаемся к памяти, а создаем новую якутку с которой можем работать, а старая так и остается. В этого ничего не работает.

Как мне ограничивать работу с уже существующей ячейкой?

P.S. Код который использую ниже, ничего необычного...

func textFieldShouldReturn(textField: UITextField) -> Bool
  {
    let rootViewPoint: CGPoint = (textField.superview?.convertPoint(textField.center, toCoordinateSpace: newOrderTableView!))!

    if let tmpIndexPath = newOrderTableView.indexPathForItemAtPoint(rootViewPoint) {
      if (tmpIndexPath.row < allLabelName.count - 1) {
        let indexPath = NSIndexPath(forRow: tmpIndexPath.row + 1, inSection: 0)
        let newCell = collectionView(newOrderTableView, cellForItemAtIndexPath: indexPath) as! EPNewOrderCollectionViewCell
        print(newCell.textField.placeholder)
        newCell.backgroundColor = UIColor.redColor()
        return true
      }
    }
 }

1 ответ 1

0

Вот для тех кто не знал...

Вместо метода

let newCell = collectionView(newOrderTableView, cellForItemAtIndexPath: indexPath) as! EPNewOrderCollectionViewCell

Нужно использовать

let newCell = newOrderTableView.cellForItemAtIndexPath(indexPath) as! EPNewOrderCollectionViewCell

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.