2012-07-27 77 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];