Порядок UITableView для willDisplay и didEndDisplaying - PullRequest
0 голосов
/ 08 октября 2019

Я столкнулся с очень странным поведением при использовании двух методов делегата

 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {

        print("will display \(indexPath.section) - \(indexPath.row)")
        addInputRules(tableView, cell, indexPath)
    }

    func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {

        print("did end display \(indexPath.section) - \(indexPath.row)")

        removeInputRules(tableView, cell, indexPath)
    }

Я добавляю и удаляю правила проверки ввода для ячеек табличного представления при прокрутке. Работает отлично. Но когда я делаю перезагрузку раздела с помощью

tableView.reloadSections(IndexSet([indexPath.section]), with: .automatic)

, появляются методы делегата willDisplay и didEndDisplaying, но в неправильном порядке!

Есть willDisplay, а после этого - EndDisplaying

will display 0 - 0
will display 0 - 1
will display 0 - 2
will display 0 - 3
will display 0 - 4
will display 0 - 5
did end display 0 - 0
did end display 0 - 1
did end display 0 - 2
did end display 0 - 3
did end display 0 - 4
did end display 0 - 5
did end display 0 - 0
did end display 0 - 1
did end display 0 - 2
did end display 0 - 3
did end display 0 - 4
did end display 0 - 5

Что вызывает удаление моих правил проверки!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...