Ich möchte, dass sich die Höhe meiner Zelle abhängig vom darin angezeigten Text ändert. Der Text wird variieren und ich möchte im Grunde, dass die Zellen ihre Größe ändern. Hier ist, was ich bisher habe:Ändern der Zellenhöhe in der Tabellenansicht Ziel 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;
}
möglich Duplikat [Erstellen eines UITableView mit Taller Zellen auf dem iPhone] (http://stackoverflow.com/questions/410224/creating- gesteuert werden a-uitableview-with-taller-cells-auf-dem-iphone) – outis