pramod aravind
pramod aravind

Reputation: 137

How to make keyboard not to popup on clicking of a TextField in swift?

I am trying to get data into textfield from UIbuttons, but when the user clicks on the textfield, the keyboard popups and if I disable the user interaction textfield, it won't allow me to use deleteBackward() method, Used when user wants to delete a character of text field.

Help please.

Upvotes: 1

Views: 2643

Answers (3)

Sagar Snehi
Sagar Snehi

Reputation: 398

put textField.resignFirstResponder() it will stop popup keyboard

Upvotes: -1

PlusInfosys
PlusInfosys

Reputation: 3446

You should create subclass of textfield and override canBecomeFirstResponder method. To NOT display keyboard, return false from canBecomeFirstResponder method.

UPDATE

If you want cursor in your textfield when you touch it, juts assign blank view to inputview.

textField.inputView = UIView();

Upvotes: 2

Vladyslav Zavalykhatko
Vladyslav Zavalykhatko

Reputation: 17354

Why don't you instead of using deleteBackward() just set text without last character? This way, you can just disable userInteraction and get exactly same results.

Along with this, you can consider using UILabel, instead of UITextField

Upvotes: 0

Related Questions