How to disable the keyboard when pressing UITextField in iOS?

I am currently developing a prototype that I want to do to test users on the desktop before downloading to the iPad.

I am looking for solutions to disable the keyboard after clicking a text field. This means that after clicking the text field, the user can directly enter information from the macbook keyboard, and the virtual keyboard, which is automatically displayed in the simulator, will not appear. I went through a lot of tutorials, but they all fire the keyboard after user login; this is not what i'm looking for. How to hide the keyboard?

Thank you very much!

+6
source share
3 answers

Use this:

UIView *dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; myTextField.inputView = dummyView; // Hide keyboard, but show blinking cursor 

It works for UITextField and UITextView, and they should be editable.

What have you done here:
You created a dummy view width=hight=0 and assigned it as the inputView of your textField .

How it works: Instead of showing the default keyboard, the viewController now shows the DummyView as an inputView for your UITextField . Since DummyView has Width=height=0 , you will not see anything on the screen :)

+5
source

This will set the inputView your text field to basically an empty UIView without a frame.

 self.theTextField.inputView = [[UIView alloc] initWithFrame:CGRectZero]; 
+1
source

Here is another answer that I found the same hacked, but with a little extra helper snippet to hide the blinking cursor.

 -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField { return NO; // Hides both keyboard and blinking cursor. } 

I need this to be done for the Quantity text box, where I increase / decrease the quantity using the UIStepper view. Therefore, I always had to hide the keyboard.

+1
source

All Articles