Когда я удаляю текущего пользователя, я также удаляю изображение из другого массива, затем вызову DeleteItems (AT
Код: Выделить всё
let indexPath = IndexPath(item: acIndex, section: 0)
exploreUsers.remove(at: acIndex)
arr_image.remove(at: acIndex)
col_exploreUser.deleteItems(at: [indexPath])
< /code>
Первое удаление работает нормально, но если я называю это несколько раз в ряду (например, удаление нескольких пользователей в последовательности), приложение сбоя с: < /p>
*** Assertion failure in -[UICollectionView _Bug_Detected_In_Client_Of_UICollectionView_Invalid_Batch_Updates:], UICollectionView.m:10798
< /code>
Что я попробовал: < /strong>
Обертывание его в exectionbatchupdates: < /p>
col_exploreUser.performBatchUpdates({
col_exploreUser.deleteItems(at: [indexPath])
}, completion: nil)
< /code>
Это код < /p>
DispatchQueue.main.async {
if let index = self.exploreUsers.firstIndex(where: { $0._id == userID }) {
print("index is this \(index) , userID is \(userID)")
let acIndex = self.getActualIndex(for: self.currentIndex, userCount: self.exploreUsers.count)
self.exploreUsers.remove(at: acIndex)
self.arr_image.remove(at: acIndex)
let indexPath = IndexPath(item: self.currentIndex, section: 0)
UIView.animate(withDuration: 0.6) {
self.col_exploreUser.performBatchUpdates({
self.col_exploreUser.deleteItems(at: [indexPath])
}, completion: { _ in
self.col_exploreUser.reloadData()
})
}
}
Добавление задержек между удалениями - все еще в конечном итоге.>
Подробнее здесь: https://stackoverflow.com/questions/797 ... invalid-ba
Мобильная версия