分组UITableView行动画怪癖 [英] Grouped UITableView row animation quirks
问题描述
我有一个带有几行的分组UITableView,并且我在按钮的切换上输入和输出更多行。问题是,对于我使用的任何行动画类型(顶部和底部),动画看起来很糟糕!这是动画中的截图:
I've got a grouped UITableView with a couple of rows, and I'm animating a few more rows in and out on the toggle of a button. The problem is that with any of the row animation types I'm using (top & bottom) the animation looks horrible! Here's a screenshot mid-animation:
示例http:/ /files.michaelwaterfall.com/images/uitableview-animation.png
有什么理由让它看起来如此糟糕?或者所有分组的表格视图动画看起来都令人震惊!?
Is there a reason why it's looking so bad? Or do all grouped table view animations look this shocking!?
我认为当一个部分的第一行或最后一行被动画时它看起来很糟糕,所以我'我只是想知道是否有办法让它看起来好一点!?否则我想我只会调用reloadData并将其全部显示出来。
I think it only looks so bad when the first or last row in a section is being animated, so I'm just wondering if there's any way to get it looking a bit better!? Otherwise I think I'll just call reloadData and have it all just appear.
感谢您的帮助!
Michael
推荐答案
如果删除,添加和/或移动 UITableView $中的多行c $ c>同时,你必须用
beginUpdates
和 endUpdates
附上所有这些电话。否则结果不确定。
If you remove, add and/or move several rows in a UITableView
at the same time, then you must enclose all these calls with beginUpdates
and endUpdates
. Otherwise the result is undetermined.
例如:
[tableView beginUpdates];
[tableView insertRowsAtIndexPaths:newRows
withAnimation:UITableViewRowAnimationTop];
[tableView deleteRowsAtIndexPaths:invalidRows:
withAnimation:UITableViewRowAnimationTop];
[tableView endUpdates];
这篇关于分组UITableView行动画怪癖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!