0

I want to add a code where if the user tap anywhere outside the Text Field, the keyboard will close. So I met this answer. But I don't know how to implement the binding to the function touchesBegan because I alloc all the view component programmatically, including the subview container and textfield within that subview container. How to do that? I think this is just a line of code, but I don't know what code to expect and what words I have to use to search on google (I've tried to search for it but can't quite find what I'm looking for), so I'm lost. Thanks.

Community
  • 1
  • 1
Chen Li Yong
  • 5,459
  • 8
  • 58
  • 124

1 Answers1

0

Your subclasses of UIViews can implement touchesBegan. You should put the touchesBegan on the UITextField superview.