I find that in iOS 8 using UITextView
sizeThatFits:
causes glitchy scrolling behavior. The Text View is constantly scrolling away from the line you are typing on. It seems to be scrolling to the top of the view and then back again.
If it matters, the view is set as an inputAccessoryView
.
Via the keyboard I'll type: 1 return 2 return 3 return 4
The TextView
the moment before I type 4
:
In the delegate method I call sizeThatFits:
.
- (void)textViewDidChange:(UITextView *)textView {
[textView sizeThatFits:CGSizeMake(100, 100)];
}
TextView
scrolls up to the top. Input happens below the view. Jittery, glitchy scrolling movement up to the top and then back to your line as you type. Input occurs under the keyboard. Extremely annoying.
If I comment out the line:
//[textView sizeThatFits:CGSizeMake(100, 100)];
Now when I type 4
we have nice, smooth typing on the last line:
The UIScrollView sizeThatFits:
docs state:
This method does not resize the receiver.
So I'm confused why this would have any effect on the scrolling/input of the textfield.
Is there any way to avoid this glitchy scrolling?
How can you calculate the "height that fits" for a Text View without hitting this bug?