Skip to content

Instantly share code, notes, and snippets.

@mattyohe
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyohe/eb80b77ea668ebeeef45 to your computer and use it in GitHub Desktop.
Save mattyohe/eb80b77ea668ebeeef45 to your computer and use it in GitHub Desktop.
HTML TextView sizing information
NSLayoutManager *layoutManager = [[self textView] layoutManager];
NSTextContainer *container = [[self textView] textContainer];
[layoutManager ensureLayoutForTextContainer:container];
CGRect rect = [layoutManager usedRectForTextContainer:container];
CGFloat height = CGRectGetHeight(rect);
UIEdgeInsets insets = [[self textView] textContainerInset];
height += insets.top;
height += insets.bottom;
height = ceilf(height);
return CGSizeMake(320, height + 16); // 16 comes from the current top and bottom cell padding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment