键盘不会消失

时间:2009-07-10 03:56:20

标签: objective-c keyboard uitextfield

在目标c中使用UITextField时,会出现键盘,键入一些图形后,我想移动到另一个文本字段或按钮,但光标从文本字段中移除,键盘也不会消失。我应该做什么?

tempTextField.borderStyle = UITextBorderStyleBezel;
tempTextField.textColor = [UIColor blackColor];
tempTextField.font = [UIFont systemFontOfSize:17.0];
tempTextField.placeholder = @"";
tempTextField.backgroundColor = [UIColor blueColor];
tempTextField.autocorrectionType = UITextAutocorrectionTypeNo;  

tempTextField.keyboardType = UIKeyboardTypeDefault; 
tempTextField.returnKeyType = UIReturnKeyDone;
tempTextField.clearButtonMode = UITextFieldViewModeNever;
tempTextField.clearButtonMode = UITextFieldViewModeNever;   
[ tempTextField setEnabled: YES ];
self.txtAirportName = tempTextField;
txtAirportName.delegate = self;
[tempTextField release];

1 个答案:

答案 0 :(得分:7)

您应该使用UIResponder的{​​{3}}方法,resignFirstResponder继承自:{/ p>

[tempTextField resignFirstResponder];