I'm subclassing NSTextView and using following code to calculate the intrinsic content size so that the height of the text view grows with it's content in my auto layout constraints.
- (CGSize)intrinsicContentSize
{
return [[self layoutManager] usedRectForTextContainer:[self textContainer]].size;
}
This works except on the initial call where it returns (0,0) for the size.
If I call [self setNeedsLayout:YES]
in my view after creating the text view and invalidate the text view's content size in -layout
it will return the correct size for the new empty text view.
Is there a way to have -intrinsicContentSize
return the correct size for my new text view without updating my view's layout?