Question

I have editable UITextView that expands as I start writing into multiple rows. At some point the height of UITextView reaches predefined maximum height and becomes scrollable. While UITextView was not scrollable everything looked nice.

When text view becomes scrollable, weird thing starts happening with spellcheck underlining red dots. Details on attached image.

first 4 lines were written while text view was not scrollable. Last 3 lines when text view was scrollable.

Can anybody help me with this? I'm sure someone has encountered it so far.

Was it helpful?

Solution

It is clearly a bug that was introduced in iOS 7 (still there for 7.0.6).

As soon as you make UITextView scrollable, spellchecker underlines are getting mashed. If you set

textView.scrollEnabled = NO;

then it's fixed.

Solution is to put your text view into scroll view and resize scroll view's content size when text grows.

Here are some screenshots. I've also made views coloured so that you can see the bounds of all text view's subviews. Interesting that with .scrollEnabled set to YES text is inserted in some other UIView which height is being calculated wrong.

.scrollEnabled == YES

enter image description here enter image description here

.scrollEnabled == NO

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top