Iphone 插入行而不重新加载表

Iphone 插入行而不重新加载表,iphone,objective-c,ios,uitableview,Iphone,Objective C,Ios,Uitableview,你好,我有tableview,里面有很多对象。如果我想在其中添加一行而不重新加载整个表。因为细胞中有一些过程。有人能帮忙吗?你可以用两种方式来做- [tableView beginUpdates]; [tableView insertRowsAtIndexPaths:newResults withRowAnimation:UITableViewRowAnimationNone]; [tableView endUpdates]; 或 这里的newResults是您需要创建的nsindepath的

你好,我有tableview,里面有很多对象。如果我想在其中添加一行而不重新加载整个表。因为细胞中有一些过程。有人能帮忙吗?

你可以用两种方式来做-

[tableView beginUpdates];
[tableView insertRowsAtIndexPaths:newResults withRowAnimation:UITableViewRowAnimationNone];
[tableView endUpdates];


这里的
newResults
是您需要创建的
nsindepath
NSArray
。然后在这些行中插入新行(带动画或不带动画)。

使用下面的委托方法

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

示例代码:为什么在这两个示例中都使用
with RowAnimation:UITableViewRowAnimationNone
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation