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

前端 未结 11 1796
有刺的猬
有刺的猬 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:40

    If you have multiple textfields say Textfield1, Textfield2, Textfield3 and you want to scroll the scrollview along the y-axis when textfield2 becomes first responder:

    if([Textfield2 isFirstResponder])
    {
        scrollView.contentOffset = CGPointMake(0,yourY);
    } 
    

提交回复
热议问题