Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hiding keyboard ios [duplicate]

I have a few text inputs and I can hide the keyboard whenever I touch the background, but only when I have been entering into the first text box name textField1. now this code should be simple but I just can't seem to get it.

-(IBAction)backgroundTouched:(id)sender {     [textField1 resignFirstResponder];     [buildLength resignFirstResponder];     [buildWidth resignFirstResponder];     [ridgeWidth resignFirstResponder];     [rafterWidth resignFirstResponder];     [hipWidth resignFirstResponder];     [eaveOverhang resignFirstResponder];     [spacing resignFirstResponder]; } 
like image 964
Builder Brent Avatar asked Apr 30 '12 19:04

Builder Brent


People also ask

How to hide the keyboard in ios?

To hide it, slide your finger down from above the text-entry box and the keyboard will start to disappear. Carry on until only the text-entry box is left. To make the keyboard reappear, tap the text-entry box and it will shoot right back up so text can be entered again.

How do you hide the keyboard on IOS 14?

To start, if you want to hide the keyboard, in most apps you can tap or tap and slide down on an area of the screen above the keyboard. This generally will hide it.


1 Answers

If you want to hide the keyboard when you tap a button and you have more than one UITextFields in your view, then you should use:

[self.view endEditing:YES]; 

Tap anywhere on the view, and the keyboard will disappear.

like image 81
Bhavin Avatar answered Sep 21 '22 13:09

Bhavin