UITableView页脚的动画问题执行“beginUpdates”“endUpdates”时查看

时间:2014-10-08 09:58:09

标签: ios uitableview animation footer

当我用动画更改单元格高度时(使用beginUpdates(),endUpdates())我的部分页脚有一个非常奇怪的动画:它在底部移动tableview。

这是我能写的最简单的代码

func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
    return "footer"
}

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return cellHeight
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    return tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    tableView.beginUpdates()
    cellHeight += 20;
    tableView.endUpdates()
}

我怎么能避免这个动画问题?

1 个答案:

答案 0 :(得分:2)

我遇到了完全相同的问题(页脚移动到tableview的底部并停留在那里)。 看起来它是一个iOS8错误(它不会发生在iOS7上)。

在我的情况下,解决方法是将页脚作为下一部分标题返回...