How to make a UIScrollView auto scroll when a UITextField becomes a first responder

前端 未结 11 1802
有刺的猬
有刺的猬 2021-01-31 03:24

I\'ve seen posts around here that suggest that UIScrollViews should automatically scroll if a subview UITextField becomes the first responder; however,

11条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-31 03:33

    Building off of Vasily Bodnarchuk's answer I created a gist with a simple protocol that you can implement and it'll do it all for you. All you need to do is call registerAsTextDisplacer()

    I created a BaseViewController in my project and made that implement it

    https://gist.github.com/CameronPorter95/cb68767f5f8052fdc70293c167e9430e

提交回复
热议问题