I have a UITextView inside a UITableViewCell. I am attempting to set the height of the UITextView it based on the content size. Inside my cellForRowAtIndexPath method I have:
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:@"CustomCell"];
....
cell.text.text = textString; // cell.text is the UITextView
CGRect frame = cell.text.frame;
frame.size.height = cell.text.contentSize.height;
cell.text.frame = frame;
return cell;
There are other objects on the custom cell, but nothing has constraints. The interesting thing is that when the table view is first loaded, the UITextView does not resize. However, when another cell is loaded by scrolling down or back up, the UITextView resizes to the correct height based on the above code. Why isn't the initial table loading correctly.
The UITextView has a default width and height size. Let me know if I can add more details. I am not implementing heightForRowAtIndexPath, but the testing I am doing has not exceeded the default cell heights so this should not matter anyways.
[UIDevice currentDevice].userInterfaceIdiom. - Abhi Beckert