Anu
Anu

Reputation: 89

Keyboard does not disappear when tapping UIPickerView

I have TableView. In each row i have textfield, three textfield have UIPickerView and two are editable, issue is when i tap on picker's textfield after tapping on editable textfield keyboard dosn't disappear here is the code

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    tf_Selected = (UITextField*)textField;
    if ([textField.placeholder isEqualToString:@"Work Order "]) {
    if (dicWorkOrderNoData.count > 0) 
    {
        [ActionSheetStringPicker showPickerWithTitle:@"Select Work Order" rows:[dicWorkOrderNoData   allValues] initialSelection:0 target:self successAction:@selector(selectPicker_ActionHandler:)  cancelAction:@selector(cancelSheet_ActionHandler) origin:textField];
    }
    else if (textField.tag == DateField_UptoCurrentDate)
    {
        [ActionSheetDatePicker showPickerWithTitle:@"Select Date" datePickerMode:UIDatePickerModeDate  selectedDate:[NSDate date] maximumDate:[NSDate date] target:self action:@selector(selectDate_ActionHandler:) cancel:@selector(cancelSheet_ActionHandler) origin:textField];
        return NO;
    }
    else
    {
        return YES;
    }
}

Upvotes: 0

Views: 113

Answers (2)

Cy-4AH
Cy-4AH

Reputation: 4585

It would better to assign to UITextField's inputAccessoryView Toolbar with [back, next, done] buttons, because you can't be sure that user actually selected pickerview's item or just scrolling them.

If you have few optionns, than use UIActionSheet instead.

Upvotes: 0

Majster
Majster

Reputation: 3701

Try using [textField resignFirstResponder];.

More on that here.

Upvotes: 1

Related Questions