ios - 如何在加载时为 UITableView 中的行设置动画?

标签 ios animation uitableview uiviewanimation

我想将 UITableViewRowAnimation 与 :reloadData 结合使用。

在我使用该示例进行表加载之前(我在一些 ios 开发指南中发现):

for (NSDictionary *entry in [dl reverseObjectEnumerator]) {
        int insertIdx = 0;

        [_allEntries insertObject:entry atIndex:insertIdx];
        [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:insertIdx inSection:0]]
                              withRowAnimation:UITableViewRowAnimationRight];

    }   

但是这种方式在大数据上似乎真的很慢,那么如何快速加载带有动画的tableviews呢?

最佳答案

您应该看看 beginUpdatesendUpdates。在这两个命令中,您可以更新/删除/插入行并为您设置动画。它也比使用 reloadData 更有效率。

更多关于此主题的信息:http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html

快速摘录:

  • (void)beginUpdates

Call this method if you want subsequent insertions, deletion, and selection operations (for example, cellForRowAtIndexPath: and indexPathsForVisibleRows) to be animated simultaneously. This group of methods must conclude with an invocation of endUpdates. These method pairs can be nested. If you do not make the insertion, deletion, and selection calls inside this block, table attributes such as row count might become invalid. You should not call reloadData within the group; if you call this method within the group, you will need to perform any animations yourself.

关于ios - 如何在加载时为 UITableView 中的行设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12011229/

相关文章:

ios - 如何在 iOS7 中以编程方式找到连接 3G 网络或 Wifi 的 iPhone 设备

html - 下拉动画延迟不工作的CSS

css - 从 0 不透明度交错淡入 div

javascript - javascript中平滑的div宽度变化

swift - 如何异步加载图像以提高 TableView 性能?

ios - 我如何在 iOS 中按字母顺序对 MediaQuery 的 artistQuery 数组进行排序

iphone - 添加为 subview 时 UITextField 不显示

ios - 如何根据选定的目标加载基本网址

ios - 如何在 viewDidLoad 方法中增加 UIView 的大小?

ios - 有没有办法操纵 NSUserDefaults 存储的信息