Size with UITextView in iOS Development

In the iOS development, the UITextView is frequently used for display a NSString with multiple lines.

In some of the applications, we need place a UITextView in UITableViewCell.

In the UITableViewCell, the height of cell is determined according to the height of UITextView, and the height of UITextView is dependent to the size of NSString which is displaying.

When we calculated the size of NSString with the methods -sizeWithFont…blablabla

It’s just the size of text.

Outside the text, there is some space edge within the UITextView, and the edge is 8px in the top and bottom direction, 11px in the left and right direction.

So, we can get the height of text first, and then add 16px to get the height of UITextView, and then calculate the height of the UITableViewCell.