IOS 鍵盤 已經textfield 自動錯誤修正等

來源:互聯網
上載者:User

標籤:style   io   ar   color   os   sp   java   for   strong   

一、鍵盤風格   

UIKit架構支援8種風格鍵盤。

  1. typedef  enum  {  
  2.     UIKeyboardTypeDefault,                 // 預設鍵盤:支援所有字元   
  3.     UIKeyboardTypeASCIICapable,            // 支援ASCII的預設鍵盤   
  4.     UIKeyboardTypeNumbersAndPunctuation,   // 標準電話鍵盤,支援+*#等符號   
  5.     UIKeyboardTypeURL,                     // URL鍵盤,有.com按鈕;只支援URL字元   
  6.     UIKeyboardTypeNumberPad,               //數字鍵台   
  7.     UIKeyboardTypePhonePad,                // 電話鍵盤   
  8.     UIKeyboardTypeNamePhonePad,            // 電話鍵盤,也支援輸入人名字   
  9.     UIKeyboardTypeEmailAddress,            // 用於輸入電子郵件地址的鍵盤   
  10. } UIKeyboardType;  

用法用例:

textView.keyboardtype = UIKeyboardTypeNumberPad;

二、鍵盤外觀

  1. typedef  enum  {  
  2.     UIKeyboardAppearanceDefault,     // 預設面板:淺灰色   
  3.     UIKeyboardAppearanceAlert,       //深灰/石墨色   
  4. } UIKeyboardAppearance;  

用法用例:

textView.keyboardAppearance=UIKeyboardAppearanceDefault;

三、斷行符號鍵

  1. typedef  enum  {  
  2.     UIReturnKeyDefault,  //預設:灰色按鈕,標有Return
  3.     UIReturnKeyGo,  //標有Go的藍色按鈕
  4.     UIReturnKeyGoogle,  //標有Google的藍色按鈕,用於搜尋
  5.     UIReturnKeyJoin,  //標有Join的藍色按鈕
  6.     UIReturnKeyNext,  //標有Next的藍色按鈕
  7.     UIReturnKeyRoute,  //標有Route的藍色按鈕
  8.     UIReturnKeySearch,  //標有Search的藍色按鈕
  9.     UIReturnKeySend,  //標有Send的藍色按鈕
  10.     UIReturnKeyYahoo,  //標有Yahoo!的藍色按鈕,用於搜尋
  11.     UIReturnKeyDone,  //標有Done的藍色按鈕
  12.     UIReturnKeyEmergencyCall,  //緊急電話按鈕
  13. } UIReturnKeyType;  

用法用例:

textView.returnKeyType=UIReturnKeyGo;

四、自動大寫

  1. typedef  enum  {  
  2.     UITextAutocapitalizationTypeNone,  //不自動大寫   
  3.     UITextAutocapitalizationTypeWords,  //單字首大寫   
  4.     UITextAutocapitalizationTypeSentences,  //句子首字母大寫   
  5.     UITextAutocapitalizationTypeAllCharacters,  //所有字母大寫   
  6. } UITextAutocapitalizationType;  

用法用例:

textField.autocapitalizationType  =  UITextAutocapitalizationTypeWords ;

五、自動校正

  1. typedef  enum  {  
  2.     UITextAutocorrectionTypeDefault, //預設   
  3.     UITextAutocorrectionTypeNo, //不自動校正   
  4.     UITextAutocorrectionTypeYes, //自動校正   
  5. } UITextAutocorrectionType;  

用法用例:

textField . autocorrectionType  =  UITextAutocorrectionTypeYes ;

六、安全文本輸入

 

textView.secureTextEntry=YES;

開啟安全輸入主要是用於密碼或一些私人資料的輸入,此時會禁用自動校正和自此緩衝。

 那麼如何設定鍵盤類型呢?

 

接下來,請看:

在TextviewDelegate的這個方法設定:

// return NO to disallow editing. - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{

       textView.keyboardtype = UIKeyboardTypeNumberPad;

      //textField.returnKeyType = UIReturnKeyYahoo;//the same as search       //textField.returnKeyType = UIReturnKeyEmergencyCall; //EmergencyCall       //textField.returnKeyType = UIReturnKeyGoogle;//the same as search       textField.returnKeyType = UIReturnKeyDefault;

}

IOS 鍵盤 已經textfield 自動錯誤修正等

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.