2014-10-08 78 views
5

当我用动画更改单元格高度(使用beginUpdates(),endUpdates())我有一个非常奇怪的动画为我的部分页脚:它正在移动到桌面的底部。UITableView页脚的动画问题执行“beginUpdates”“endUpdates”时的视图

这里是最简单的代码,我可以写

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() 
} 

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

+0

我想知道这个代码将如何甚至不工作。 'cellHeight + = 20'是什么意思? – 2014-10-08 10:02:50

+0

它停留在底部还是只是暂时的状态? – Amandir 2014-10-10 14:17:47

+0

看看这篇文章http://stackoverflow.com/questions/5740518/uitableview-footer-stop-from-floating-over-content – 2016-05-19 02:45:40

回答

2

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

在我的情况下,解决方法是返回页脚下一节头......