Iphone 如何在UITableView中重新加载单个节

Iphone 如何在UITableView中重新加载单个节,iphone,uitableview,nsindexpath,Iphone,Uitableview,Nsindexpath,嘿,我在想这个问题时遇到了麻烦。UITableView现在有一个方法[tableView reloadSections:(NSIndexSet*)with RowAnimation:(UITableViewRowAnimation)],根据Apple文档,该方法接收NSIndexSet对象并重新加载索引集指定的任何部分。问题是,即使我只发送了一个部分到这个方法,它最终会重新加载所有的部分,我不明白为什么会发生这种情况。非常感谢您提供的任何帮助即使您尝试只重新加载一个部分,您也必须逐部分提供填充过

嘿,我在想这个问题时遇到了麻烦。UITableView现在有一个方法[tableView reloadSections:(NSIndexSet*)with RowAnimation:(UITableViewRowAnimation)],根据Apple文档,该方法接收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;
}

。。。因为重新加载表(它只是一个部分还是整个表)将调用上述方法,即使您尝试只重新加载一个部分,也必须逐节提供填充过程:

- (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;
}

。。。因为重新加载表(它只是一个部分还是整个表)将调用上述方法

可能您弄错了NSIndexSet?[tableView重新加载节:[NSIndexSet indexSetWithIndex:indexPath.section]withRowAnimation:animation];那就是确切的路线。当用户单击一行时,它应该调用以重新加载该行中用户单击的部分可能是您弄错了NSIndexSet吗?[tableView重新加载部分:[NSIndexSet indexSetWithIndex:indexPath.section]withRowAnimation:animation];那就是确切的路线。当用户单击一行时,它应该调用以重新加载该行中用户单击的部分。嗯,我现在明白你在说什么了。我需要做的是回答我的另一个问题,也许你能帮我。[链接]如果我回答了你当前的问题,你最好接受它,在我开始关注你的下一个链接之前,嗯,我明白你现在在说什么了。我需要做的是回答我的另一个问题,也许你能帮我。[链接]好吧,如果我回答了你当前的问题,在我开始关注你的下一个链接之前,你最好接受它