Merci pour vos réponses, je vais mettre le code ici. Mais rappelez-vous que mon code fonctionne bien pour toutes les autres cellules, donc il doit être lié au contenu spécifique de cette cellule, mais ce n'est qu'un texte dans un UILabel ...
N'hésitez pas à consulter la vidéo J'ai fait, c'est un comportement très curieux pour l'iPhone, as-tu vu ça? dl.free.fr/rlQmFyWS0
Voici le code pour cellForRowAtIndexPath: méthode, juste la partie concernée par la cellule de description:
case 3: // A big cell containing the description
{
// Try to find an already allocated cell with the description (note : there is only one description cell per table so no need to check the content...)
UITableViewCell * descriptionCell = [tableView dequeueReusableCellWithIdentifier:kTextCellIdentifier];
if (descriptionCell == nil) {
// As a frame, use the description label's one plus a little margin for the height
descriptionCell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, self.descriptionText.frame.size.height + (2*kCellInset)) reuseIdentifier:kTextCellIdentifier] autorelease];
descriptionCell.selectionStyle = UITableViewCellSelectionStyleNone;
// The descriptionText UILabel has been previously initialized properly by tableview:heightForRowAtIndexpath: method
[descriptionCell.contentView addSubview:self.descriptionText];
}
return descriptionCell;
Et voici la partie où j'initialisés le champ descriptionText:
// Customize row height for each cell
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 3) {
CGSize realSize;
if (self.descriptionText != nil) {
// the description has been previously initialized
realSize = descriptionText.frame.size;
}
else {
// We need to dynamically resolve the height for the description zone
NSString * desc = (NSString *)[product objectForKey:@"description"];
UILabel * descLabel = [[UILabel alloc] initWithFrame:CGRectZero];
// Unlimited number of lines
descLabel.numberOfLines = 0;
descLabel.text = desc;
// Set a preferred width and anything for the height
realSize = [descLabel sizeThatFits:CGSizeMake(tableView.frame.size.width - (2*kCellInset), 1)];
// Take the opportunity to set the frame with the correct values
descLabel.frame = CGRectMake(kCellInset, kCellInset, realSize.width, realSize.height);
self.descriptionText = descLabel;
[descLabel release];
}
return (realSize.height + (2*kCellInset));
}
else {
return kImageCellHeight;
}
return 0;
}
Toute estimation serait plus que bienvenu ... Je continue ici
enquêtais 0
Bonne supposition, j'ai essayé, mais ne change rien ... – Unfalkster
L'en-tête section « Description » ne devrait pas causer de problème. C'est une chaîne normale! – lostInTransit