iOS 给tableViewCell添加动画

来源:互联网 发布:适合男人的眼霜 知乎 编辑:程序博客网 时间:2024/05/14 14:57
当增加数据源时不能使用[tableView reloadData]; ,因为会影响动画效果.
    NSInteger number = _arr.count;    self.indexPaths = [NSMutableArray array];    for (NSInteger i = 0; i < _arr.count - 1; i++) {          NSString *str = @"hello";          NSIndexPath *indexPath = [NSIndexPath indexPathForRow:number + i inSection:0];          [self.arr addObject:str];          [_indexPaths addObject: indexPath];    }        [self.tableView insertRowsAtIndexPaths:_indexPaths withRowAnimation:UITableViewRowAnimationBottom];

0 0