【问题标题】:UITableView row/cell animationUITableView 行/单元格动画
【发布时间】:2016-04-20 19:41:41
【问题描述】:

我有一个 UITableView,为此我使用新数据重新加载每一行:

for currentIndex in (feeds.count-1).stride(through: 0, by: -1) {
    self.feedList[currentIndex] = feeds[currentIndex]

    dispatch_async(dispatch_get_main_queue()) {
        self.tableView.beginUpdates()

        self.tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: currentIndex, inSection: 0)], withRowAnimation: UITableViewRowAnimation.Middle)
        self.tableView.endUpdates()
    }
}

这会使所有行同时动画化。我想要的是让每一行一个接一个地设置动画。我怎样才能做到这一点?

【问题讨论】:

  • 您是否尝试过使用 CATransaction 并一次只为一行设置动画,并在 CATransaction 的完成块中调用下一行的动画?

标签: ios swift uitableview animation reload


【解决方案1】:

评论者对CATransaction 的看法是正确的。 Here 是一个示例,说明如何将您拥有的内容与 CATransaction 结合起来以获得正确的动画序列。保存您想要设置动画的步幅,然后再迭代一个元素,直到您将它们全部设置为动画。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-20
    • 2017-06-15
    • 2012-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多