【问题标题】:Insert row without reloading table插入行而不重新加载表
【发布时间】:2011-12-28 11:22:33
【问题描述】:

您好,我有一个包含许多对象的 tableview。如果我想在其中添加一行而不重新加载整个表。因为细胞中有一些过程。有人可以帮忙吗?

【问题讨论】:

标签: iphone objective-c ios uitableview


【解决方案1】:

你可以通过两种方式做到这一点 -

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

[tableView insertRowsAtIndexPaths:newResults withRowAnimation:UITableViewRowAnimationNone];

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

【讨论】:

  • 为什么在这两个例子中都使用withRowAnimation:UITableViewRowAnimationNone
【解决方案2】:

使用下面的委托方法

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

【讨论】:

    猜你喜欢
    • 2015-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多