Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide keyboard on view disappear or button click iphone

I have a table view on a view and table view contains custom cells and cell contains text box. and i want to hide the keyboard when user click on save button or user navigate from the view. i already have hide the keyboard on done button.. plz can any one suggest.

like image 479
Mitesh Khatri Avatar asked Sep 16 '10 11:09

Mitesh Khatri


People also ask

How do you hide keyboard on iPhone iOS 15?

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.

How do I minimize the keyboard on my iPhone 13?

Tap the left keyboard icon to shrink the keyboard to the left-hand side of the screen. Tap the right keyboard icon to shrink the keyboard to the right-hand side of the screen. To make the keyboard full-size again, tap the middle keyboard icon. You can also tap the arrow next to the one-handed keyboard to reset it.


2 Answers

If you want to hide the keyboard with the tap of a button and if you have many text fields and the user can be on any field. Then you can use this code:

[self.view endEditing:YES];

Tap any where on view, and keyboard will dissappear..

Njoy.. :)

like image 164
NiKKi Avatar answered Oct 12 '22 06:10

NiKKi


Use the following code

- (void)viewWillDisappear:(BOOL)animated 
{
    [textField resignFirstResponder];

}

It will dismiss your keyboard when ever your view is dismissed.

If on clicking save button your view is not getting dismissed then on SAVE button Click event also you have to write [textField resignFirstResponder]; else it will work.

Update: If you cannot track the textfield or there are too many textfields then using

[self.view endEditing:YES];

in your viewWillDisappearwill do the trick.

like image 43
Suresh Varma Avatar answered Oct 12 '22 05:10

Suresh Varma