Uitableview 具有不同标识符的自定义TableViewCell
我有从数组生成的自定义原型单元格的tableviewUitableview 具有不同标识符的自定义TableViewCell,uitableview,identifier,Uitableview,Identifier,我有从数组生成的自定义原型单元格的tableview cellLabel = [[NSArray alloc] initWithObjects: @"20 Последних новостей", @"Политика", @"Экономика", @"Право", @"Происшествия", @"Культура",
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,所以我可以在代码中使用行标识符。无论如何,谢谢你 谢谢你,但是如果你选择它,它会显示没有标签和图像的白细胞:(没问题。将来,如果你对某人发布的答案有回复,只需添加它作为评论。