How to show keyboard after used inputView

╄→尐↘猪︶ㄣ 提交于 2019-12-09 10:50:02

问题


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;

回答1:


Just

textfield.inputView = nil;

worked for me




回答2:


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];



回答3:


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];
  }
}


来源:https://stackoverflow.com/questions/11696419/how-to-show-keyboard-after-used-inputview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!