How to resign first responder from text field when user tap elsewhere?

前端 未结 18 3151
野趣味
野趣味 2020-12-14 02:12

I have filled my view with ScrollView (same size as the view) and I\'m stuck at how to resign first responder when user tap elsewhere in the View (or the scrollview). Any id

18条回答
  •  心在旅途
    2020-12-14 02:36

    I found an answer here: link

    If your ultimate aim is just to resign the first responder, this should work: [self.view endEditing:YES]

    This method is designed right for it! Reference: endEditing:

    Causes the view (or one of its embedded text fields) to resign the first responder status.

提交回复
热议问题