Return 个具有不同小区标识符的小区

Return cells with different cell identifiers

我有一个包含多个单元格标识符的自定义单元格。我尝试了以下代码:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    NSString *cellID;
    switch ([indexPath section]) {
        case 0:
            cellID = @"firstCell";
            break;
        case 1:
            cellID = @"secondCell";
            break;

        default:
            break;
    }

    customCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];

    return cell;
 }

当我 运行 应用程序时,它显示第一个单元格 2 次,即使在情节提要中,有 2 个单元格内部有不同的对象。

[indexPath section]真的是你想要的吗? 我想你想要 [indexPath row]