当我使用动画(使用 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()
}
我怎样才能避免这个动画问题?
最佳答案
我遇到了完全相同的问题(页脚移动到表格 View 的底部并停留在那里)。 看起来这是一个 iOS8 错误(在 iOS7 上不会发生)。
在我的例子中,解决方法是将页脚作为下一个节的标题返回...
关于ios - 执行 "beginUpdates" "endUpdates"时 UITableView 页脚 View 的动画问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26254125/