Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用inputView后如何显示键盘_Ios_Xcode_Uitextfield_Uipickerview_Inputview - Fatal编程技术网

Ios 使用inputView后如何显示键盘

Ios 使用inputView后如何显示键盘,ios,xcode,uitextfield,uipickerview,inputview,Ios,Xcode,Uitextfield,Uipickerview,Inputview,我使用inputView为我的textfield显示uipickerview,但对其他函数使用相同的textfield。在我为该textfield使用inputView后,如何显示标准键盘 textfield.inputView = pickrView; 只是 textfield.inputView=nil 为我工作我想这个代码也许可以工作 [textField.inputView addTarget:self action:@selector(doTest) forControlEvent

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

textfield.inputView = pickrView;
只是

textfield.inputView=nil


为我工作

我想这个代码也许可以工作

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

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

正如Pavel Kaljunen所说,您只需将inputView设置为nil,但当键盘已经可见时,您必须首先放弃FirstResponder,将inputView设置为nil,然后再次成为FirstResponder

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

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

[UIView commitAnimations];

textfield.inputView=否;为我工作您最好使用nil或NULL而不是NO。inputView属性需要UIView而不是BOOL。尽管这对NO有效,因为nil和NO都是数字0,但如果指定YES,这将失败并崩溃。