Move UIView up when the keyboard appears in iOS

后端 未结 18 1815
再見小時候
再見小時候 2020-11-28 20:38

I have a UIView, it is not inside UIScrollView. I would like to move up my View when the keyboard appears. Before I tried to use this solution: How can I make a UITextField

18条回答
  •  抹茶落季
    2020-11-28 20:46

    It can be done easily & automatically if that textfield is in a table's cell (even when the table.scrollable = NO).

    NOTE that: the position and size of the table must be reasonable. e.g:

    • if the y position of table is 100 counted from the view's bottom, then the 300 height keyboard will overlap the whole table.
    • if table's height = 10, and the textfield in it must be scrolled up 100 when keyboard appears in order to be visible, then that textfield will be out of the table's bound.

提交回复
热议问题