shoe
shoe

Reputation: 1070

How to add long press functionality to a UITextField

I added a UILongPressGestureRecognizer to a UITextField only to find that the only thing that got triggered was the UITextField's magnifying glass; and then when the magnifying glass disappeared the context menu appeared.

What do I have to do in order for my UILongPressGestureRecognizer to be triggered instead of the default behavior?

I've already tried disabling all UILongPressGestureRecognizers before adding my own, as per some other SO answers, but to no avail.

Upvotes: 0

Views: 413

Answers (1)

user5890979
user5890979

Reputation:

Put a UIView on top of the textField with the same frame. Make it clear background. Add your gestures to your UIView and handle custom selections from there on. Make a tap gesture to start editing the text manually. And make a longpressgesture to do whatever you want. etc.

Upvotes: 2

Related Questions