Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text jumps down in UITextField when editing

I'm having a weird issue here. Textfield’s bounds change when textfield becomes firstResponder and rolls back when resigns.

In other words, when I tap on the textfield to change the text, text jumps down.

I'm using system font with size 16. I have two different UITextFields, one with border and one without border but same happens to both of them.

Any ideas why this is happening and how to fix it ?

This is what happens

Update

So after testing for a few days, I realized that this issue only happens on iOS 10

like image 252
Mehrshid Avatar asked Oct 30 '17 09:10

Mehrshid


2 Answers

Based on my experience this is an iOS 10 bug and the only way to resolve in my case was to make the height of my UITextField to equal the text height (based on font type, you need different relations between font size and UITextField height).

For example if the height of the UITextField is 30 points the system font size must be 20. Hope it works for you too.

like image 96
Hamid Baraghani Avatar answered Nov 02 '22 23:11

Hamid Baraghani


I got the same problem. (Spent more than 1 day for this issue).

In my case, the solution is that turn off automaticallyAdjustsScrollViewInsets of UIViewController.

like image 21
tuledev Avatar answered Nov 03 '22 00:11

tuledev