我只想重新加载一部分而不是整个表格。有没有什么方法UITableView
.
[tableView reloadData]
用于加载全表。
我想知道如何仅加载一个部分,因为表中有大量行。
reloadSections 方法让我烦恼——因为我必须构造一些对象。如果您需要灵活性,这非常棒,但有时我也只想要简单性。事情是这样的:
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];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)