Je souhaite que la taille de ma cellule change en fonction du texte affiché. Le texte variera et je veux essentiellement que les cellules changent de taille. Voici ce que j'ai jusqu'à présent:Modification de la hauteur de la cellule dans la vue de table Objectif C
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DefaultCell1"];
CGRect cellRectangle;
if (cell == nil) {
cellRectangle = CGRectMake(0.0, 0.0, 300, 110);
cell = [[[UITableViewCell alloc] initWithFrame:cellRectangle reuseIdentifier:@"DefaultCell1"] autorelease];
}
UILabel *label;
cellRectangle = CGRectMake(10, (40 - 20)/2.0, 280, 110);
//Initialize the label with the rectangle.
label = [[UILabel alloc] initWithFrame:cellRectangle];
label.lineBreakMode = UILineBreakModeWordWrap;
label.numberOfLines = 20;
label.font = [UIFont fontWithName:@"Helvetica" size:11.0];
label.text = [[self.person.statusMessages objectAtIndex:indexPath.row] valueForKey:@"text"];
CGFloat height = [label.text sizeWithFont:label.font].height;
//So right here is where I think I need to do something with height and
//see it to something tied to he cell
[cell.contentView addSubview:label];
[label release];
return cell;
}
double possible de [Création d'un UITableView avec Taller cellules sur l'iPhone] (http://stackoverflow.com/questions/410224/creating- a-uitableview-with-taller-cells-on-the-iphone) – outis