繁体   English   中英

如何在使用inputView后显示键盘

[英]How to show keyboard after used inputView

我使用inputView为我的textfield显示uipickerview ,但我对其他函数使用相同的textfield 在将inputView用于该textfield后,如何显示标准键盘?

textfield.inputView = pickrView;

只是

textfield.inputView = nil;

为我工作

正如Pavel Kaljunen所说,你只需要将inputView设置为nil,但是当键盘已经可见时,你必须首先使用resignFirstResponder,将inputView设置为nil然后再次设置为FirstResponder。

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

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

[UIView commitAnimations];

我认为这段代码可能有用

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

- (void)doTest
{
  if([textFiled isFirstResponder])
  {
    [textFiled resignFirstResponder];
  }
  else
  {
    [textFiled becomeFirstResponder];
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM