是否为tableView iOS中的扩展单元格加载自定义XIB?

是否为tableView iOS中的扩展单元格加载自定义XIB?,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我正在尝试为选中的UITableViewCell加载扩展单元格XIB。我的普通单元格和扩展单元格的内容几乎相同,只是在扩展单元格中填充了一些视图的额外空间。现在为了区分普通单元格和扩展单元格,我更改了UILabel颜色在展开的单元格内以不同的颜色显示。我可以在单击单元格时加载展开的单元格XIB但是问题是每个单元格都被展开的单元格XIB所取代。唯一的区别是,单击的单元格的高度比其他单元格高。当我单击后退时,展开的单元格单元格,再次加载正常单元格XIB。如何仅为单击的单元格加载扩展单元格XIB?还是

我正在尝试为选中的
UITableViewCell
加载扩展单元格XIB。我的普通单元格和扩展单元格的内容几乎相同,只是在扩展单元格中填充了一些视图的额外空间。现在为了区分普通单元格和扩展单元格,我更改了
UILabel
颜色在展开的单元格内以不同的颜色显示。我可以在单击单元格时加载展开的单元格XIB但是问题是每个单元格都被展开的单元格XIB所取代。唯一的区别是,单击的单元格的高度比其他单元格高。当我单击后退时,展开的单元格单元格,再次加载正常单元格
XIB
。如何仅为单击的单元格加载扩展单元格
XIB
?还是有更好的方法来实现这一目标

这是我如何扩展细胞的

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{


if ([self.expandedCells containsObject:indexPath]) {

    [self.expandedCells removeAllObjects];
    isExpanded = NO;
    [self.busTableView beginUpdates];
    [self.busTableView reloadData];
    [self.busTableView endUpdates];

}else{
    isExpanded=YES;

    if (self.expandedCells.count>0) {
        [self.expandedCells removeAllObjects];
    }

    [self.expandedCells addObject:indexPath];
    expCell.expContainer.hidden=YES;

     //Some more code

    [self.busTableView beginUpdates];
    [self.busTableView reloadData];
    [self.busTableView endUpdates];

   }

}
cellForRow
方法如下所示

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

  if (!isExpanded) {   //BOOL variable set to NO in viewDidLoad initially

    BusListCell *cell =(BusListCell*) [tableView dequeueReusableCellWithIdentifier:nil];
    if (cell==nil) {
    NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:@"BusListCell" owner:self options:nil];
        cell = nibs[0];

    }
    cell.busName.text = [[busArray objectAtIndex:indexPath.row]valueForKey:@"operatorName"];

    return cell;

 }else{
      expCell = (ExpandedCell*)[tableView dequeueReusableCellWithIdentifier:nil];
      if (expCell==nil) {
         NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:@"ExpandedCell" owner:self options:nil];
        expCell = nibs[0]; 

       }

       expCell.bus_Name.text = [[busArray objectAtIndex:indexPath.row]valueForKey:@"operatorName"];
       return expCell;

      }

    return nil;
  }

而不是签入cellForRowAtIndexPath:

if (!isExpanded) {}
你必须检查一下

if (![self.expandedCells containsObject:indexPath]){}

非常感谢。为我节省了很多时间:-)