UIKeyboard鍵盤相關知識點-IOS開發

一、鍵盤風格   

UIKit框架支持8種風格鍵盤。

[java] view plaincopy
  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;  
[java] view plaincopy
  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;

二、鍵盤外觀

[java] view plaincopy
  1. typedef enum {  
  2.     UIKeyboardAppearanceDefault,    // 默認外觀:淺灰色   
  3.     UIKeyboardAppearanceAlert,      //深灰/石墨色   
  4. } UIKeyboardAppearance;  
[java] view plaincopy
  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;

四、自動大寫

[java] view plaincopy
  1. typedef enum {  
  2.     UITextAutocapitalizationTypeNone, //不自動大寫   
  3.     UITextAutocapitalizationTypeWords, //單詞首字母大寫   
  4.     UITextAutocapitalizationTypeSentences, //句子首字母大寫   
  5.     UITextAutocapitalizationTypeAllCharacters, //所有字母大寫   
  6. } UITextAutocapitalizationType;  
[java] view plaincopy
  1. typedef enum {  
  2.     UITextAutocapitalizationTypeNone, //不自動大寫  
  3.     UITextAutocapitalizationTypeWords, //單詞首字母大寫  
  4.     UITextAutocapitalizationTypeSentences, //句子首字母大寫  
  5.     UITextAutocapitalizationTypeAllCharacters, //所有字母大寫  
  6. } UITextAutocapitalizationType;  
用法用例:

textField.autocapitalizationType = UITextAutocapitalizationTypeWords;

五、自動更正

[java] view plaincopy
  1. typedef enum {  
  2.     UITextAutocorrectionTypeDefault,//默認   
  3.     UITextAutocorrectionTypeNo,//不自動更正   
  4.     UITextAutocorrectionTypeYes,//自動更正   
  5. } UITextAutocorrectionType;  
[java] view plaincopy
  1. typedef enum {  
  2.     UITextAutocorrectionTypeDefault,//默認  
  3.     UITextAutocorrectionTypeNo,//不自動更正  
  4.     UITextAutocorrectionTypeYes,//自動更正  
  5. } UITextAutocorrectionType;  
用法用例:

textField.autocorrectionType = UITextAutocorrectionTypeYes;

六、安全文本輸入

textView.secureTextEntry=YES;

開啓安全輸入主要是用於密碼或一些私人數據的輸入,此時會禁用自動更正和自此緩存。

七、鍵盤遮住視圖

這個問題又來已久,我專門寫了篇文章來解決此問題,請笑納:《 打開鍵盤遮住View的問題解決方法》

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章