我的应用使用了tableView
,该更新通过批量更新进行了更新。
单元格的indicatorImage
取决于表的部分。
当单元格在各部分之间移动时,此指示器会发生变化,我想为指示器图像的变化设置动画。
为此,我首先使用tableView.performBatchUpdates
为单元格的删除,插入和移动设置动画。
其次,我将批量更新嵌入到CATransaction
块中,以动画化图像更改。
除了一个例外,这非常有效:
如果在表视图更新期间应显示警报,则我的应用程序将在UITableViewAlertForLayoutOutsideViewHierarchy
断点处停止。
这是代码:
CATransaction.begin()
tableView.performBatchUpdates({
tableView.deleteRows(at: deletions,with: .automatic)
tableView.insertRows(at: insertions,with: .automatic)
for (from,to) in movements {
tableView.moveRow(at: from,to: to)
if from.section == kTableSectionBought {
if let cell = tableView.cellForRow(at: from) {
let indicatorImage = to.section < 2 ? self.progressImages!.first : self.progressImages!.last
UIView.transition(with: cell.imageView!,// see <https://stackoverflow.com/a/40472115/1987726>
duration: 0.25,options: .transitionCrossDissolve,animations: { cell.imageView!.image = indicatorImage },completion: nil)
}
}
}
animateCells(deletions: deletions,movements: movements)
},completion: { (finished) in
// some code
}
我的问题是:
该错误的可能原因是什么,我该如何避免?
PS:我读过this question,但没有答案,相反,我的UIWindow
已定义。