一、键盘类型
UIKit框架支持8种风格键盘。
typedef enum {-
UIKeyboardTypeDefault, // 默认键盘:支持所有字符
-
UIKeyboardTypeASCIICapable, // 支持ASCII的默认键盘
-
UIKeyboardTypeNumbersAndPunctuation, // 标准电话键盘,支持+*#等符号
-
UIKeyboardTypeURL, // URL键盘,有.com按钮;只支持URL字符
-
UIKeyboardTypeNumberPad, //数字键盘
-
UIKeyboardTypePhonePad, // 电话键盘
-
UIKeyboardTypeNamePhonePad, // 电话键盘,也支持输入人名字
-
UIKeyboardTypeEmailAddress, // 用于输入电子邮件地址的键盘
-
} UIKeyboardType;
-
用法用例:
textView.keyboardtype= UIKeyboardTypeNumberPad;
UIKeyboardTypeDefault:
UIKeyboardTypeASCIICapable:
UIKeyboardTypeNumbersAndPunctuation:
UIKeyboardTypeURL:
UIKeyboardTypeNumberPad:
UIKeyboardTypePhonePad:
UIKeyboardTypeNamePhonePad:
UIKeyboardTypeEmailAddress:
UIKeyboardTypeDecimalPad:
UIKeyboardTypeTwitter:
UIKeyboardTypeWebSearch:
UIKeyboardTypeAlphabet:
二 键盘高度
//获取键盘的高度
/*
iphone 6:
中文
2014-12-31 11:16:23.643 Demo[686:41289] 键盘高度是 258
2014-12-31 11:16:23.644 Demo[686:41289] 键盘宽度是 375
英文
2014-12-31 11:55:21.417 Demo[1102:58972] 键盘高度是 216
2014-12-31 11:55:21.417 Demo[1102:58972] 键盘宽度是 375
iphone 6 plus:
英文:
2014-12-31 11:31:14.669 Demo[928:50593] 键盘高度是 226
2014-12-31 11:31:14.669 Demo[928:50593] 键盘宽度是 414
中文:
2015-01-07 09:22:49.438 Demo[622:14908] 键盘高度是 271
2015-01-07 09:22:49.439 Demo[622:14908] 键盘宽度是 414
iphone 5 :
2014-12-31 11:19:36.452 Demo[755:43233] 键盘高度是 216
2014-12-31 11:19:36.452 Demo[755:43233] 键盘宽度是 320
ipad Air:
2014-12-31 11:28:32.178 Demo[851:48085] 键盘高度是 264
2014-12-31 11:28:32.178 Demo[851:48085] 键盘宽度是 768
ipad2 :
2014-12-31 11:33:57.258 Demo[1014:53043] 键盘高度是 264
2014-12-31 11:33:57.258 Demo[1014:53043] 键盘宽度是 768
*/
以下几种键盘类型几乎一样,键盘高度也是一样的
UIKeyboardTypeAlphabet
UIKeyboardTypeASCIICapable
UIKeyboardTypeDefault
UIKeyboardTypeEmailAddress
UIKeyboardTypeNamePhonePad
UIKeyboardTypeNumbersAndPunctuation(数字和标点符号)
UIKeyboardTypeTwitter
UIKeyboardTypeURL
UIKeyboardTypeWebSearch
5.5吋271
4.7吋258
4.0吋253
②以下几种键盘为数字类型的键盘,键盘高度也是一样的
UIKeyboardTypeDecimalPad(带小数点的数字键盘)
UIKeyboardTypeNumberPad(纯数字键盘)
UIKeyboardTypePhonePad(带*+#,;的数字键盘)
5.5吋226
4.7吋216
4.0吋216