【问题标题】:Keyboard doesn't disappear键盘没有消失
【发布时间】:2010-11-09 14:33:39
【问题描述】:

在目标 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];

【问题讨论】:

    标签: objective-c keyboard uitextfield


    【解决方案1】:

    你应该使用UIResponderresignFirstResponder方法,UITextField继承自:

    [tempTextField resignFirstResponder];
    

    【讨论】:

    • 经典。我想几乎每个人都错过了这一点。我知道当我第一次开始 iPhone 开发时我就是这么做的。
    • 有点奇怪。 Becoming firstResponder 是自动的(好吧,当用户触摸 textField 时)但是当他们触摸外部时,它不会 resignFirstResponder。我同意,这确实有点不直观。
    • 这可能就是每个人都被键盘抓住的原因。如果收购和辞职都是自动的,或者都是手动的,我认为这不是问题。
    • 虽然很有趣,I did that exactly to customize UIAlertView 但从未消失。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-21
    • 1970-01-01
    • 1970-01-01
    • 2018-05-30
    • 2011-03-05
    • 2011-08-21
    相关资源
    最近更新 更多