Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone:Is it possible to hide keyboard while tapping UITextField?

In my application I have to fill UITextField from the value exist in UIPickerView not through keyboard.

I have 2 UITextFields. In 1st textfield value is fetched from keyboard and in 2nd textfield value is fetched from UIPickerView

so on tapping 2nd textfield I want to hide keyboard and show UIPickerView

here I add what I do for your better reference

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
      [pickerToolBar setHidden:NO];//shows toolbar
        [pickerTime setHidden:NO];//shows UIPickerView
        [textField resignFirstResponder];
}

but after writing the above code the keyboard does not disappear.

if you have any idea then plz help me...

like image 758
iPhone Avatar asked Dec 26 '11 06:12

iPhone


People also ask

Which method can be used to dismiss the system keyboard if a UITextField or Uitextview is currently being edited?

You can ask the system to dismiss the keyboard by calling the resignFirstResponder method of your text field. Usually, you dismiss the keyboard in response to specific interactions. For example, you might dismiss the keyboard when the user taps the keyboard's return key.


1 Answers

Try UITextfield delegate methods. put the following code in texfield didBeginEditing method.

[texfield resignfirstresonder];

Then the text field will block editing and keyboard will not appear. Make sure you attached the text field delegate to the file owner.

like image 115
mashios Avatar answered Oct 16 '22 14:10

mashios