我用inputView
來顯示我的textfield
的uipickerview
,但我用其他功能相同的textfield
。在我爲使用inputView
後,如何顯示標準鍵盤?如何使用inputView後顯示鍵盤
textfield.inputView = pickrView;
我用inputView
來顯示我的textfield
的uipickerview
,但我用其他功能相同的textfield
。在我爲使用inputView
後,如何顯示標準鍵盤?如何使用inputView後顯示鍵盤
textfield.inputView = pickrView;
只是
textfield.inputView = nil;
工作對我來說
你最好使用零或NULL而不是NO。 inputView屬性需要UIView而不是BOOL。儘管這可以與NO一起使用,因爲nil和NO都是數字0,如果您分配YES,這將失敗並崩潰。 – 2012-07-28 04:59:31
好的..謝謝! – 2012-07-28 08:31:02
它不適用於我:( – HusseinB 2013-08-14 18:46:44
我覺得這個代碼,也許可以工作
[textField.inputView addTarget:self action:@selector(doTest) forControlEvents:UIControlEventTouchUpInside];
- (void)doTest
{
if([textFiled isFirstResponder])
{
[textFiled resignFirstResponder];
}
else
{
[textFiled becomeFirstResponder];
}
}
由於帕維爾Kaljunen說,你只需要設置inputView到零,但是當鍵盤已經可見時,您必須先辭職FirstR首先,將inputView設置爲零,然後再次成爲FirstResponder。
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.35];
[yourTextField resignFirstResponder];
yourTextField.inputView = nil;
[yourTextField becomeFirstResponder];
[UIView commitAnimations];
textfield.inputView = NO;爲我工作 – 2012-07-27 22:36:14