2012-07-27 9 views
5

の場合はinputViewを表示し、textfieldの場合はuipickerviewと表示しましたが、他の機能には同じtextfieldを使用します。 textfieldinputViewを使用した後、標準キーボードを表示するにはどうすればよいですか?使用後にキーボードを表示する方法

textfield.inputView = pickrView; 
+0

textfield.inputView = NO; –

答えて

10

ちょうど

textfield.inputView = nil;

は私のために働い

+1

あなたはNOの代わりにnilまたはNULLを使うのがよいでしょう。 inputViewプロパティはBOOLではなくUIViewを必要とします。これはnilとしてNOで動作しますが、NOは両方とも数値0ですが、YESを指定すると失敗し、クラッシュします。 –

+0

Ok ..ありがとう! –

+3

それは私と一緒に働いていない:( – HusseinB

0

私は、このコードは多分パベルKaljunenが言ったように

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

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

は、あなたがinputViewを設定するだけ働くことができると思いますキーボードはすでに表示されているときには、最初にresignする必要があります最初に、inputViewをnilに設定し、次にbecomeFirstResponderを再度設定します。

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

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

[UIView commitAnimations]; 
関連する問題