【发布时间】:2016-04-04 10:11:19
【问题描述】:
我正在尝试在另一行删除动画完成后插入一行。我一直在尝试执行以下操作:
tableView.beginUpdates()
CATransaction.begin()
CATransaction.setCompletionBlock {
tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Right)
}
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Left)
CATransaction.commit()
tableView.endUpdates
当行数与预期不同时,这给了我通常的断言失败。
然后我尝试使用带有完成块的UIView 动画:
tableView.beginUpdates()
func animations() {
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Left)
}
func completion() {
if count == self.payments.count && self.payments.isEmpty { insert() }
}
UIView.animateWithDuration(0.5, animations: { animations() }) { _ in completion() }
tableView.endUpdates()
两次尝试都给了我同样的错误。是否有可能或者我应该研究用于插入/删除 tableview 行的自定义动画?
编辑:
我设法通过将tableView.endUpdates() 移动到完成块来使其工作。但是插入动画在删除行的同时仍然有动画。
还有其他方法吗?
【问题讨论】:
标签: ios swift uitableview animation