Я использую tableview
с custom cell
.
У моего пользовательского cell
есть ярлык, и я определил его outlet
в 'StatutoryMappingCell.h'
Следуя методу 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
не отображаются, когда я запускаю свой код. Но почему это так?
Это моя сцена раскадровки
2 ответа
Посмотрите в свой конструктор интерфейса - у вас не должно быть conntected
вашей пользовательской ячейки, вы должны установить ее как files owner
, если да, проверьте, подключены ли метки или нет,
Попробуйте этот код
-(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;
}
Похожие вопросы
Новые вопросы
ios
iOS - мобильная операционная система, работающая на Apple iPhone, iPod touch и iPad. Используйте этот тег [ios] для вопросов, связанных с программированием на платформе iOS. Используйте связанные теги [target-c] и [swift] для проблем, характерных для этих языков программирования.