How to scroll view up when keyboard appears?

后端 未结 7 1532
小蘑菇
小蘑菇 2021-01-31 02:54

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 incre

7条回答
  •  爱一瞬间的悲伤
    2021-01-31 03:28

    Since I found it, I use TPKeyboardAvoiding - https://github.com/michaeltyson/TPKeyboardAvoiding.

    It is working great, and is very easy to setup:

    • Add a UIScrollView into your view controller's xib
    • Set the scroll view's class to TPKeyboardAvoidingScrollView (still in the xib, via the identity inspector)
    • Place all your controls within that scroll view

    You can also create it programmatically, if you want.


    There is a class for the same need inside a UITableViewController ; it is only needed in case you support a version of iOS below 4.3.

提交回复
热议问题