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,这将失败并崩溃。