我正在使用tableview
custom cell
。
我的自定义cell
已贴上标签,我已在{StatutoryMappingCell.h'
outlet
遵循isn cellForRowAtIndexPath
方法,
StatutoryMappingCell * cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
if (!cell)
{
[tableView registerNib:[UINib nibWithNibName:@"KnowledgeMainCell" bundle:nil] forCellReuseIdentifier:@"myCell"];
cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
}
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(StatutoryMappingCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.statMapping.text = [self.items objectAtIndex:indexPath.row];
}
问题是我运行代码时cells
不可见。但为什么会这样呢?
这是我的故事板场景
答案 0 :(得分:1)
查看您的界面构建器 - 您没有conntected
您的自定义单元格,您应将其设置为files owner
,如果是,则检查标签是否已连接,
答案 1 :(得分:1)
试试这些代码
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"identifier";
CellItemList *cellA = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cellA == nil)
{
// Load the top-level objects from the custom cell XIB.
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:(isIpad)?@"CellItemList~ipad":@"CellItemList" owner:self options:nil];
// Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
cellA = (CellItemList *)[topLevelObjects objectAtIndex:0];
}
cellA.statMapping.text = [tableData objectAtIndex:indexPath.row];
return cellA;
}