I'm trying to create a UITableViewCell that contains a UITextView and when the user enters text into the textview the cell should grow accordingly.
This also works quite well so far, except that the boundingRectWithSize method ignores trailing line breaks when calculating the new cell size. This is what my method call looks like:
CGRect rect = [text boundingRectWithSize:CGSizeMake(self.cellSize.width, CGFLOAT_MAX)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:[UIFont fontWithName:@"AvenirNext-Medium" size:14.0]}
context:nil];
If I for example enter
Test
\n
\n
(line breaks visualised as "\n"), the method returns the size for a textview containing two lines and not three.
I tried several options and als attributes but couldn't find a solution that works. How can I do this in a functioning way?