一、鍵盤風格
UIKit框架支持8種風格鍵盤。
- typedef enum {
- UIKeyboardTypeDefault,
- UIKeyboardTypeASCIICapable,
- UIKeyboardTypeNumbersAndPunctuation,
- UIKeyboardTypeURL,
- UIKeyboardTypeNumberPad,
- UIKeyboardTypePhonePad,
- UIKeyboardTypeNamePhonePad,
- UIKeyboardTypeEmailAddress,
- } UIKeyboardType;
用法用例:
textView.keyboardtype = UIKeyboardTypeNumberPad;
二、鍵盤外觀
- typedef enum {
- UIKeyboardAppearanceDefault,
- UIKeyboardAppearanceAlert,
- } UIKeyboardAppearance;
用法用例:
textView.keyboardAppearance=UIKeyboardAppearanceDefault;
三、回車鍵
- typedef enum {
- UIReturnKeyDefault, //默認:灰色按鈕,標有Return
- UIReturnKeyGo, //標有Go的藍色按鈕
- UIReturnKeyGoogle, //標有Google的藍色按鈕,用于搜索
- UIReturnKeyJoin, //標有Join的藍色按鈕
- UIReturnKeyNext, //標有Next的藍色按鈕
- UIReturnKeyRoute, //標有Route的藍色按鈕
- UIReturnKeySearch, //標有Search的藍色按鈕
- UIReturnKeySend, //標有Send的藍色按鈕
- UIReturnKeyYahoo, //標有Yahoo!的藍色按鈕,用于搜索
- UIReturnKeyDone, //標有Done的藍色按鈕
- UIReturnKeyEmergencyCall, //緊急呼叫按鈕
- } UIReturnKeyType;
用法用例:
textView.returnKeyType=UIReturnKeyGo;
四、自動大寫
- typedef enum {
- UITextAutocapitalizationTypeNone,
- UITextAutocapitalizationTypeWords,
- UITextAutocapitalizationTypeSentences,
- UITextAutocapitalizationTypeAllCharacters,
- } UITextAutocapitalizationType;
用法用例:
textField.autocapitalizationType = UITextAutocapitalizationTypeWords ;
五、自動更正
- typedef enum {
- UITextAutocorrectionTypeDefault,
- UITextAutocorrectionTypeNo,
- UITextAutocorrectionTypeYes,
- } 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;
}
那么如何控制某種類型的特定的一個按鈕的顯示或者隱藏,可以做到嗎?
待.......