2012-07-27 81 views
5

我用inputView来显示我的textfielduipickerview,但我用其他功能相同的textfield。在我为使用inputView后,如何显示标准键盘?如何使用inputView后显示键盘

textfield.inputView = pickrView; 
+0

textfield.inputView = NO;为我工作 – 2012-07-27 22:36:14

回答

10

只是

textfield.inputView = nil;

工作对我来说

+1

你最好使用零或NULL而不是NO。 inputView属性需要UIView而不是BOOL。尽管这可以与NO一起使用,因为nil和NO都是数字0,如果您分配YES,这将失败并崩溃。 – 2012-07-28 04:59:31

+0

好的..谢谢! – 2012-07-28 08:31:02

+3

它不适用于我:( – HusseinB 2013-08-14 18:46:44

0

我觉得这个代码,也许可以工作

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

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

由于帕维尔Kaljunen说,你只需要设置inputView到零,但是当键盘已经可见时,您必须先辞职FirstR首先,将inputView设置为零,然后再次成为FirstResponder。

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

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

[UIView commitAnimations];