我只想重新加载一部分而不是整个表格。 UITableView
中有没有方法。
[tableView reloadData]
用于加载完整表格。
我想知道如何仅加载一个部分,因为表中有大量行。
最佳答案
reloadSections 方法让我烦恼——因为我必须构造一些对象。如果您需要灵 active ,这非常棒,但有时我也只想要简单性。事情是这样的:
NSRange range = NSMakeRange(0, 1);
NSIndexSet *section = [NSIndexSet indexSetWithIndexesInRange:range];
[self.tableView reloadSections:section withRowAnimation:UITableViewRowAnimationNone];
这将重新加载第一部分。我更喜欢在 UITableView 上有一个类别,然后调用这个方法:
[self.tableView reloadSectionDU:0 withRowAnimation:UITableViewRowAnimationNone];
我的类别方法如下所示:
@implementation UITableView (DUExtensions)
- (void) reloadSectionDU:(NSInteger)section withRowAnimation:(UITableViewRowAnimation)rowAnimation {
NSRange range = NSMakeRange(section, 1);
NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
[self reloadSections:sectionToReload withRowAnimation:rowAnimation];
}
关于iphone - UITableView 重新加载部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8306792/