簡體   English   中英

如何禁用 UITextField 中的雙擊鍵盤彈出窗口?

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

我有幾個 UITextFields。 我想禁用帶來自動更正/鍵盤的“雙擊”。 我正在使用水龍頭 function 來選擇要激活的 UITextField。

您可以使用 UITextView 的textFieldShouldBeginEditing委托方法告訴 UITextField 不要開始編輯過程:

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

蘋果文檔參考方法: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html

some condition可能會檢查用戶是否選擇 UITextField 來激活它,或者它是否已經處於活動狀態並且應該啟動鍵盤。

您可以將 UITextView 子類化以賦予它“選定”屬性,並使其成為 UITextViewDelegate。 如果 "selected" 為 false,則在textFieldShouldBeginEditing:中將其設置為 true 並返回 NO; 否則,返回 YES。 這只是我腦海中的一個隨機想法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM