UITapGestureRecognizer does not work for custom subclass of UITextField

I created my own subclass of UITextField, CustomTextView.

  • I created

    private var tapGesture = UITapGestureRecognizer()
    

    in class customTextView

  • In initInView, I have the following code

    tapGesture.addTarget(self, action: "tapTextField:")
    self.addGestureRecognizer(tapGestureRecognizer)
    
  • CustomTextView implements UIGestureRecognizerDelgate

  • CustomTextView has a private function called tapTextField

Now when I use the iOS simulator and click on the text field, the tapTextField function is never called.

What am I missing here? I saw similar notes, but none of them answered my question. I could not comment on them, because I do not have a reputation yet. Therefore, asking a new question.

PS: Is it related to installing firstResponder? This is someone else code I'm working on, so I might have missed something. Let me know what I should look for

Related questions:

+4
2

, "tapTextField:" "tapTextField" , // "tapTextField".

,

self.addGestureRecognizer(tapGestureRecognizer) self.addGestureRecognizer(tapGesture)

+1

, .

1 > , tapTextField tapTextField:, , - .

2 > , - uitextfield. 3 > po yourTextFieldName xcode, , - , .

,

0

All Articles