I know that this question has been asked over and over again, but nothing seems to be working for me. Most of the solutions around are pretty out of date, and the rest are incredibly huge blocks of code that are ten times larger then the actual projects coding. I have a few UITextFields lined up vertically, but when the keyboard launches to edit one, it covers up the text field. I was wondering if there is a simple beginner way to scroll the view up, and then back down when the editing starts and ends?
Thank you.
Set fitsSystemWindows = "false" and set android:windowSoftInputMode="adjustResize" in manifest file. Show activity on this post. I have used like this to show the soft keyboard programatically and this is worked for me to prevent the auto resize of the screen while launching the keyboard.
I have made solutions that work with scroll and non-scroll views using keyboard notification and a detection of the current first responder, but sometimes I use this trivial solution instead: The simple way is to detect the opening keyboard via the text field delegate's textViewDidBeginEditing:
method and to move the entire view up. The easiest way to do this is with something along the lines of changing self.view.bounds.origin.y
to -100 (or whatever). Use the corresponding textViewShouldEndEditing:
method to set it to the opposite, which is 100 in this case. Changing bounds
is a relative procedure. After changing it the frame is moved but the bounds origin is still zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With