Я использую 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 не отображаются, когда я запускаю свой код. Но почему это так?

Это моя сцена xib ... введите описание изображения здесь

Это моя сцена раскадровки

enter image description here

-1
user6092898 2 Май 2016 в 13:28

2 ответа

Лучший ответ

Посмотрите в свой конструктор интерфейса - у вас не должно быть conntected вашей пользовательской ячейки, вы должны установить ее как files owner, если да, проверьте, подключены ли метки или нет,

0
Anbu.Karthik 2 Май 2016 в 10:37

Попробуйте этот код

-(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;
}
0
kajal 2 Май 2016 в 11:15