简体   繁体   English

如何禁用 UITextField 中的双击键盘弹出窗口?

[英]How do you disable the double tap keyboard popup in a UITextField?

I have several UITextFields.我有几个 UITextFields。 I want to disable the "double tap" that brings the autocorrection/keyboard.我想禁用带来自动更正/键盘的“双击”。 I'm using a tap function to chose which UITextField to activate.我正在使用水龙头 function 来选择要激活的 UITextField。

You can tell a UITextField not to begin the editing process using the textFieldShouldBeginEditing Delegate method of UITextView:您可以使用 UITextView 的textFieldShouldBeginEditing委托方法告诉 UITextField 不要开始编辑过程:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
  if (some conditon) {
    return NO;
  } else {
    return YES;
  }
}

Apple documentation reference on the method: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html苹果文档参考方法: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html

some condition would likely be a check to see whether the user is selecting the UITextField to activate it, or whether it is already active and it should bring the keyboard up. some condition可能会检查用户是否选择 UITextField 来激活它,或者它是否已经处于活动状态并且应该启动键盘。

You could subclass UITextView to give it a "selected" property, and make it a UITextViewDelegate.您可以将 UITextView 子类化以赋予它“选定”属性,并使其成为 UITextViewDelegate。 If "selected" is false, then set it to true in textFieldShouldBeginEditing: and return NO;如果 "selected" 为 false,则在textFieldShouldBeginEditing:中将其设置为 true 并返回 NO; otherwise, return YES.否则,返回 YES。 That's just one random idea off the top of my head.这只是我脑海中的一个随机想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM