Anthony
Anthony

Reputation: 2801

The keyboard does not hide with two UITextField with one who calls a picker

I have two UITexfield, one normal and a second who calls my custom picker. The problem is, when I put text in my first UITextfield and after I tap on my second for call the picker, the keyboard doesn't Hide.

My code:

-(void)textFieldDidBeginEditing:(UITextField *)textField{

    if (textField.tag == 5) {//UITextField who call picker
        [tfNumber resignFirstResponder];
        [tfDate resignFirstResponder];

        datePicker = [[ANDatePickerView alloc]initWithSuperView:self.view delegate:self];
        [datePicker appears];
    } 
}

The picker appears bellow the keyboard.

Where is de problem ?

Upvotes: 0

Views: 142

Answers (2)

Engnyl
Engnyl

Reputation: 1380

Add this line to the end of the method that shows your pickerView;

[self.view endEditing:YES];

Upvotes: 1

kirti Chavda
kirti Chavda

Reputation: 3015

try this code:

     - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;
        {
          if (textField.tag == 5)
          {
   datePicker = [[ANDatePickerView alloc]initWithSuperView:self.view delegate:self];
        [datePicker appears];
           return NO;

          }
          return YES;
        }

Upvotes: 1

Related Questions