Here's my code. It's pretty much the same once I realized I was using
something that is SDK 3.0. I've included the stuff that's in 2.0 since
that's public.
// Add this method to the class with the tableView to change the
height for each row at an indexPath
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:
(NSIndexPath *)indexPath {
if (indexPath.section == sectionThatShouldBeResized) {
CGSize textSize = [textThatGoesInLabel sizeWithFont:[UIFont
systemFontOfSize:sizeOfText]
constrainedToSize:CGSizeMake(270.0, 99999999)
lineBreakMode:UILineBreakModeWordWrap];
return (textSize.height + 20 > 44) ? textSize.height + 20 : 44; //
Add twenty for funny stuff. Also, I limit the size here to 44 because
I use accessories and it looks bad if it's less than that. Change this
to fit your own needs.
}
return 44; //Otherwise, return the default size of 44
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
if (indexPath.section == sectionThatShouldBeResized) {
CellIdentifier = @"CellIdentifierOne";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
// Err… my code can't be displayed here b/c it uses SDK 3.0 stuff.
But just make a label like david
// said and you use these 3 lines to configure it.
newLabel.font = [UIFont systemFontOfSize:kInstructionFontSize];
newLabel.lineBreakMode = UILineBreakModeWordWrap;
newLabel.numberOfLines = 0; //This allows the textLabel to have as
many lines as necessary
}
newLabel.text = textThatGoesInLabel;
return cell;
}
return nil;
}