[英]How to reload a single section in a UITableView
嘿,我很難弄清楚這一點。 現在,根據Apple文檔,UITableView有一種方法[tableView reloadSections:(NSIndexSet *)withRowAnimation:(UITableViewRowAnimation)],該方法將使用NSIndexSet對象並重新加載索引集指定的任何部分。 問題是,即使即時消息僅向該方法發送一個部分,但最終卻會重新加載所有部分,而我不明白為什么會這樣。 任何幫助將不勝感激
即使您嘗試僅重新加載一個部分,也必須逐節提供填充過程:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"DetailViewCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
if (indexPath.section == 0){
//blablabla
cell.textLabel = blabla
}
else if (indexPath.section == 1){
///blablabla
cell.textLabel = blabla2
}
return cell;
}
...因為重新加載表(是僅一部分還是整個表)將調用上述方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.