I wnat my cell's height to change depending on the text being displayed in it. The text will vary and I'm basically wanting the cells to change size. Here is what I have so far:
- (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;
}