UITableView 添加单元格动画 [英] UITableView add cell Animation

查看:42
本文介绍了UITableView 添加单元格动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能帮我解决 UITableView 动画问题吗?

Can any one help me out with UITableView animating issue?

默认情况下,我们在 UITableView 中有删除单元格和重新排序单元格的动画.

By default we have animation for deleting cell and reordering cells in UITableView.

我们可以动画添加单元格吗,如果可以怎么做.

Can we have animated adding cell, if so how to do it.

我查看了 Three20,不知道 twitter 如何在 MyProfile>ReTweets 下完成表格展开动画.

I have checked out Three20, did not not get how twitter has done the table expand animation under MyProfile>ReTweets.

想在没有Three20 frameowrk的情况下尝试一下,使用UITableView中已有的动画.

Want to try it without Three20 frameowrk, using the existing animation in UITableView.

推荐答案

您可以使用以下 UITableView 方法:

You can use the following UITableView method:

- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation

示例,self.dataSource 是一个可变数组,而您的表只有 1 个部分:

Example with self.dataSource being a mutable array and your table only having 1 section:

[self.dataSource addObject:@"New Item"];
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:[self.dataSource count]-1 inSection:0];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];

注意:从数据源计数中减去 1,因为 NSIndexPath 是零索引的.

Note: Subtracted 1 from datasource count since NSIndexPath is zero indexed.

这篇关于UITableView 添加单元格动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆