绘制UITableviewcell时的动画

时间:2012-02-07 06:39:41

标签: iphone objective-c ios xcode

我有一个完全正常的UITableView,有删除,排序,插入等等。

如何在将单元格添加到UITableView时将Fading,Middle或Down等动画设置为UITableViewCell,而不是在使用UITableViewCellEditingStyleInsert时,而是在从数组添加项目时< / p>

1 个答案:

答案 0 :(得分:0)

您是否尝试为添加的每个对象插入一个单元格(insertRowsAtIndexPaths:withRowAnimation:)?

可能是这样的:

- (void)addContentFromArray:(NSArray *)array {
    [self.tableView beginUpdates];
    NSMutableArray *indexPaths = [NSMutableArray arrayWithCapacity:[array count]];
    for (id object in array) {
        NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:[self.dataSource count] inSection:0];
        [self.dataSource addObject:object];
    }
    [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic];
    [self.tableView endUpdates];
}
相关问题