- In my App, I have a table view with cell style value2: (cell have two labels side by side).
- In textLabel, I displayed time: which was displayed in timeLable.
- in detailTextLable, I displayed comments which was entered in commentsTextView
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
cell.detailTextLabel.numberOfLines = 0;
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
}
cell.textLabel.text = timelabel.text;
cell.detailTextLabel.text = commentTextView.text;
}
//int x = cell.commentTextView.frame.size.height;
}
cell.detailTextLabel.textAlignment = UITextAlignmentLeft;
cell.textLabel.textAlignment = UITextAlignmentLeft;
return cell;
}
-
I need to expand my cell size with respect to the length of comments entered in a text view :’commentTextView’ displayed in detailTextLabel.
-
But the difference in the textLable (timelable text), it does not expand along with detailTextLabel
what to do?
This is always tricky to get right, for the height you need to do implement something like this.