Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Uitableview 具有不同标识符的自定义TableViewCell_Uitableview_Identifier - Fatal编程技术网

Uitableview 具有不同标识符的自定义TableViewCell

Uitableview 具有不同标识符的自定义TableViewCell,uitableview,identifier,Uitableview,Identifier,我有从数组生成的自定义原型单元格的tableview cellLabel = [[NSArray alloc] initWithObjects: @"20 Последних новостей", @"Политика", @"Экономика", @"Право", @"Происшествия", @"Культура",

我有从数组生成的自定义原型单元格的tableview

cellLabel = [[NSArray alloc] initWithObjects:
             @"20 Последних новостей",
             @"Политика",
             @"Экономика",
             @"Право",
             @"Происшествия",
             @"Культура",
             @"Здоровье",
             @"Технологии",
             @"В Мире",
             @"Калейдоскоп",
             nil];
我的问题是如何在创建单元格时为每个单元格设置自己的不同reuseIdentifier 或者我需要做10个不同的细胞

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

static NSString *CellId = @"Sections";

sectionCell *Cell = [tableView dequeueReusableCellWithIdentifier:CellId];

if (!Cell) {

    Cell = [[sectionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellId];

}

Cell.sectionTitle.text = [cellLabel objectAtIndex:indexPath.row];


return Cell;
}


谢谢

我不确定我会建议对每个动态生成的单元使用不同的重用标识符,但如果您愿意,可以执行以下操作:

 switch (indexPath.row) {
        case 0:
            cell = [tableView dequeueReusableCellWithIdentifier:@"1"];
            break;
        case 1:
            cell = [tableView dequeueReusableCellWithIdentifier:@"2"];

        default:
            break;
    }
cell.textLabel.text = [cellLabel objectAtIndex:indexPath.row];

我只是糊涂了。我得到了indexpath.row.com,所以我可以在代码中使用行标识符。无论如何,谢谢你

谢谢你,但是如果你选择它,它会显示没有标签和图像的白细胞:(没问题。将来,如果你对某人发布的答案有回复,只需添加它作为评论。