1
Je suis en train d'afficher un TableView personnalisé sur un UIViewController mais je reçois une erreur « UITableView dataSource doit retourner une cellule de tableView: cellForRowAtIndexPath: »TableauViewCells personnalisé sur un UIViewController?
j'avais connecté le TableView à DataSource et délégué.
Une suggestion à propos de l'implémentation ou ai-je besoin d'un UITableViewController?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *)
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle]
loadNibNamed:@"CustomCell"
owner:nil options:nil];
for (id currentObjects in topLevelObjects){
if ([currentObjects isKindOfClass:[UITableView class]]){
cell = (CustomCell *) currentObjects;
break;
}
}
}
//---set the text to display for the cell---
cell.cellNameLabel.text = @"This is name";
cell.cellValueLabel.text = @"This is Value";
return cell;
Désolé, je n'ai pas posté le code entier. Je vais éditer ma question. –
après edit dites-moi –
J'ai vu votre réponse éditée. Toujours le même problème. –