开发者

UIScrollview implemented, but UITextfields still covered by keyboard

开发者 https://www.devze.com 2023-02-23 18:44 出处:网络
I have gone through most of the posts here and on the internet. I did find a lot of the answers I was looking but one problem remains and I am not sure how to solve it: Basically, I have a setup in IB

I have gone through most of the posts here and on the internet. I did find a lot of the answers I was looking but one problem remains and I am not sure how to solve it: Basically, I have a setup in IB as follows:

UIScrollview implemented, but UITextfields still covered by keyboard

There are several text fields that the user fills in one by one. However when the user finishes with the "City" text field, he has to press "DONE" on the keyboard to resign it, only then can he go to the "Telephone" field and fill the rest. I have implemnted the method to move the view up when the user starts editing the "Telephone" field but that only happe开发者_开发百科ns when the "Telephone" field is clicked. But, going from top to bottom, after finishing the "City" field, the user doesn't even see the "Telephone" field, so how can he click on it and consquently, how can the view move up? Im confused. I have implemented a scroll view but when I try to scroll the screen up nothing happens.

UIScrollview implemented, but UITextfields still covered by keyboard

UIScrollview implemented, but UITextfields still covered by keyboard

UIScrollview implemented, but UITextfields still covered by keyboard


try using https://github.com/michaeltyson/TPKeyboardAvoiding mentioned in this post https://stackoverflow.com/a/8590988/364413


Here are two tutorials that move the textfields up when the Keyboard appears.

https://web.archive.org/web/20160316104414/http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/

http://iosdevelopertips.com/user-interface/adjust-textfield-hidden-by-keyboard.html


Just scrolling won't help here - you need to resize the whole view.

Subscribe to UIKeyboardWillShowNotification, UIKeyboardWillHideNotification notifications and resize the scroll view there: make it smaller by the keyboard size when the keyboard is shown, and larger when it goes away. You can get the keyboard size by getting the value under UIKeyboardFrameBeginUserInfoKey key in the notification's userInfo.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号