键盘不消失(Keyboard doesn't disappear)

2019-10-16 20:45发布

虽然在客观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];

Answer 1:

您应该使用resignFirstResponder方法UIResponder ,其中UITextField继承自:

[tempTextField resignFirstResponder];


文章来源: Keyboard doesn't disappear