J'ai créé un UITableViewCell personnalisé à partir d'un NIB. Tout apparaît lorsque le rowHeight n'est pas défini (bien que tout soit écrasé). Je ne sais pas si je suis réutilisez et de créer les cellules correctement:UITableViewCell n'apparaît pas/ne se réutilise pas correctement depuis NIB
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"ARCell";
ARObject *myARObject;
myARObject = [items objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"ARCell" owner:self options:nil];
cell = arCell;
self.arCell = nil;
}
UILabel *label;
label = (UILabel *)[cell viewWithTag:0];
label.text = [NSString stringWithFormat:@"%@", myARObject.username];
label = (UILabel *)[cell viewWithTag:1];
label.text = [NSString stringWithFormat:@"%@", myARObject.created_at];
label = (UILabel *)[cell viewWithTag:2];
label.text = [NSString stringWithFormat:@"%@", myARObject.articleTitle];
label = (UILabel *)[cell viewWithTag:3];
label.text = [NSString stringWithFormat:@"%@", myARObject.intro_text];
return cell;
}
- (CGFloat)tableView:(UITableView *)tblView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ CGFloat rowHeight = 105;
return rowHeight;
}
Problèmes:
- Toutes les étiquettes apparaissent lorsque rowHeight est réglé. Si rowHeight n'est pas défini, les étiquettes sont écrasées
- Lorsque rowHeight n'est pas défini, la sélection d'un élément indique toutes les étiquettes
existe toujours –