【发布时间】:2011-12-28 11:22:33
【问题描述】:
您好,我有一个包含许多对象的 tableview。如果我想在其中添加一行而不重新加载整个表。因为细胞中有一些过程。有人可以帮忙吗?
【问题讨论】:
标签: iphone objective-c ios uitableview
您好,我有一个包含许多对象的 tableview。如果我想在其中添加一行而不重新加载整个表。因为细胞中有一些过程。有人可以帮忙吗?
【问题讨论】:
标签: iphone objective-c ios uitableview
你可以通过两种方式做到这一点 -
[tableView beginUpdates];
[tableView insertRowsAtIndexPaths:newResults withRowAnimation:UITableViewRowAnimationNone];
[tableView endUpdates];
或
[tableView insertRowsAtIndexPaths:newResults withRowAnimation:UITableViewRowAnimationNone];
这里的newResults 是您需要创建的NSIndexPath 中的NSArray。然后在这些行中插入新行(带有或不带有动画)。
【讨论】:
withRowAnimation:UITableViewRowAnimationNone?
使用下面的委托方法
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
【讨论】: