UITextView issue - caret jumps upwards
I have a UIVie开发者_运维知识库wController with a UITextView as its subview. Its as simple a hierarchy as that. When I tap inside the textview, the caret(cursor) jumps upwards by 10 px as if the return key was hit magically and whatever I type is there but gives a clipped look. What could be the reason? Any fix?
textView.contentInset = UIEdgeInsetsZero;
Solves the caret jump issue.
Had the same problem on iOS 8. When manually update .attributedText property of the textView together with .selectedRange (to move the caret), the caret jumps upwards for a moment and then comes back where it supposed to be. The solution with setting contentInset to UIEdgeInsetsZero didn't work for me. In my case, the solution was to set:
_textView.scrollEnabled = NO;
2019: I had similar issue for iPhoneX+ after disabling contentInsetAdjustmentBehavior the issue is resolved.
textView?.contentInsetAdjustmentBehavior = .never
精彩评论