谁能帮我解决 UITableView
动画问题?
默认情况下,我们在 UITableView
中有删除单元格和重新排序单元格的动画。
我们可以动画添加单元格吗?如果可以的话,怎么做。
我查看了Three20,没明白twitter
是如何在MyProfile>ReTweets下做表格展开动画的。
想在没有 Three20 frameowrk
的情况下尝试使用 UITableView
中现有的动画。
最佳答案
您可以使用以下 UITableView 方法:
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
self.dataSource 是一个可变数组并且您的表只有 1 个部分的示例:
[self.dataSource addObject:@"New Item"];
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:[self.dataSource count]-1 inSection:0];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
注意:由于 NSIndexPath 的索引为零,因此从数据源计数中减去 1。
关于ios - UITableView 添加单元格动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3122934/