我正在构建一个自定义分组表视图,当部分为 0 时,需要在 indexPath.row=0 处显示一个自定义表视图单元。我能够显示它,但是一旦我进入 tableView 的底部,所有单元格都会发生变化
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *listData =[self.tableContents objectForKey:[self.sortedKeys objectAtIndex:[indexPath section]]];
static NSString *simpleTableIdentifier = @"Cell";
if (indexPath.row==0 && indexPath.section==0)
{
RightLabelCell *cell = (RightLabelCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"RightLabelSetting" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.leftLabel.text = [listData objectAtIndex:indexPath.row];
cell.rightLabel.text=@"RightLabel";
return cell;
}
else
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
cell.textLabel.text = [listData objectAtIndex:indexPath.row];
return cell;
}
}
并且还崩溃cell.leftLabel.text = [listData objectAtIndex:indexPath.row];