I am experiencing a crash when I delete a row.
// Updating my data model
....
// apply the updates
self.tableView.beginUpdates()
self.tableView.deleteRows(at: indexPathsToDelete, with: .automatic)
self.tableView.endUpdates()
Steps to reproduce - Add rows - Delete rows, specifically making sure there's some rows outside the current screen (that will then be in screen when the deletion is successful - Repeat until crash occurs
It doesn't always happen so my best guess is that it will happen only when the cells it's trying to load get recycled
This is in 10.0 simulator with Xcode 8.0
*** Assertion failure in -[UITableView _updateWithItems:updateSupport:],
/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3599.6/UITableView.m:3149
Missing cell for newly visible row 2
(null)
code for cellForRowAt
if isMultipe{
let cell = tableView.dequeueReusableCell(withIdentifier: DetailsTableViewCell.defaultIdentifier, for: indexPath) as! DetailsTableViewCell
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: DetailsMultipleTableViewCell.defaultIdentifier, for: indexPath) as! DetailsMultipleTableViewCell
return cell
}
the same bug reported here : https://forums.developer.apple.com/thread/49676
I had the same problem and I found out that UITableView
has serious problems with animating insert/update/delete rows when section headers are variable height. Just convert the height to some constant and try it again.
This actually means deleting estimatedSectionHeaderHeight
.
In my case it was crashing when cells have used autolayout for calculating it's height. So, the only guaranteed solution is use manual calculating heights. (what is actually sad..)
In my case I had this issue just for inserting the first row to an empty section, so I tried to fix it like this:
self.array.append(item)
if self.array.count > 1 {
self.tableView.beginUpdates()
self.tableView.insertRows(at: indexPathes, with: .top)
self.tableView.endUpdates()
} else {
self.tableView.reloadSections([1], with: .fade)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With