Search code examples
swiftuitextviewtouchesbegan

touchesBegan not called on UITextField


I have created a simple test project with a single UITextView and the touchesBegan method in the view controller. For some reason, the UITextView is not responding to touchesBegan.

Things I have tried:

  • Alpha is set to 1
  • User interaction is enabled on the view and the UITextView
  • Delay Touch Down is unchecked
  • The background is set to a solid color

I found similar questions in several places, but none of the solutions have worked.


Solution

  • While it seems like others have successfully gotten touchesBegan to work on a UITextField in the past, nothing seems to be working now. Instead, I simply added textFieldDidBeginEditing and canceled the animation from there. Problem solved.