10

I used inputView to show uipickerview for my textfield, but I use same textfield for other functions. How can I show standard keyboard after I used inputView for that textfield?

textfield.inputView = pickrView;
Pavel Kaljunen
  • 1,291
  • 2
  • 26
  • 53

3 Answers3

15

Just

textfield.inputView = nil;

worked for me

Pavel Kaljunen
  • 1,291
  • 2
  • 26
  • 53
  • 1
    you'd better use nil or NULL instead of NO. The inputView property expects an UIView and not a BOOL. Although this works with NO as nil and NO are both a numerical 0, this will fail and crash if you assign YES. –  Jul 28 '12 at 04:59
5

As Pavel Kaljunen said, you need only to set the inputView to nil, but when the keyboard is already visible, you have to resignFirstResponder first, set the inputView to nil and then becomeFirstResponder again.

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.35];

[yourTextField resignFirstResponder];
yourTextField.inputView = nil;
[yourTextField becomeFirstResponder];

[UIView commitAnimations];
MPajak
  • 99
  • 1
  • 7
0

i think this code maybe can work

 [textField.inputView addTarget:self action:@selector(doTest) forControlEvents:UIControlEventTouchUpInside];

- (void)doTest
{
  if([textFiled isFirstResponder])
  {
    [textFiled resignFirstResponder];
  }
  else
  {
    [textFiled becomeFirstResponder];
  }
}
cloosen
  • 993
  • 7
  • 17