[英]Reload UITableView except one section of it
I have a tableView with multiple sections. 我有一个tableView有多个部分。
Now I want to reload all sections of tableView except the first one (because it's static and doesn't change). 现在,我想重新加载tableView的所有部分,除了第一个部分(因为它是静态的并且不会改变)。
I now I can reload sections by this method: 我现在可以通过这种方法重新加载部分:
reloadSections(IndexSet, with: UITableView.RowAnimation)
but it requires the number of sections and in my app this is dynamic and changes in time. 但它需要部分的数量,并且在我的应用中这是动态的,并且会随时间变化。
I can only say reload whatever exist after first section. 我只能说重装第一节之后的内容。
I thought I should define a IndexSet
somehow like this: 我以为我应该这样定义一个IndexSet
:
NSIndexSet *indexSet = [NSIndexPath indexPathWithIndexes:(NSUInteger[]){1, ... } length:???];
and I don't know how can I do that! 我不知道该怎么办!
Any ideas or suggestion would be greatly appreciated. 任何想法或建议将不胜感激。
update 更新
This is the numberOfSectionsInTableView
implementation: 这是numberOfSectionsInTableView
实现:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
// Inbox Segment
if (self.selectedIndex == 0) {
if (self.inboxArray.count > 0) {
return self.inboxArray.count + 2;
}
}
// Sent Segment
else if (self.selectedIndex == 1) {
if (self.sentArray.count > 0) {
return self.sentArray.count + 2;
}
}
// Outbox Segment
else if (self.selectedIndex == 2) {
if (self.outboxArray.count > 0) {
return self.outboxArray.count + 2;
}
}
// Spam Segment
else if (self.selectedIndex == 3) {
if (self.spamArray.count > 0) {
return self.spamArray.count + 2;
}
}
// Trash Segment
else if (self.selectedIndex == 4) {
if (self.trashArray.count > 0) {
return self.trashArray.count + 2;
}
}
return 1;
}
Assuming you know the amount of sections: 假设您知道部分的数量:
NSIndexSet *sectionsIndexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, self.sections.count - 1)]
[self.tableView reloadSections:sectionsIndexSet withRowAnimation:UITableViewRowAnimationNone];
Swift: 迅速:
let sectionsIndexSet = IndexSet(1..<sections.count)
tableView.reloadSections(sectionsIndexSet, with: .none)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.