http://blog.csdn.net/h3c4lenovo/article/details/8447661
First, the keyboard style
The Uikit Framework supports 8 styles of keyboards.
- typedef ENUM {
- Uikeyboardtypedefault,//default keyboard: All characters supported
- Uikeyboardtypeasciicapable,//ASCII-enabled default keyboard
- Uikeyboardtypenumbersandpunctuation,//Standard telephone keypad, supports +* #等符号
- Uikeyboardtypeurl,//URL keyboard with. com button; URL characters only
- Uikeyboardtypenumberpad,//numeric keypad
- Uikeyboardtypephonepad,//Telephone keypad
- Uikeyboardtypenamephonepad,//telephone keypad, also support input person name
- Uikeyboardtypeemailaddress,//keyboard for entering e-mail addresses
- } Uikeyboardtype;
Usage Use cases:
Textview.keyboardtype= Uikeyboardtypenumberpad;
Second, keyboard appearance
- typedef ENUM {
- Uikeyboardappearancedefault,//default appearance: Light grey
- Uikeyboardappearancealert,//dark grey/Graphite
- } uikeyboardappearance;
Usage Use cases:
Textview.keyboardappearance=uikeyboardappearancedefault;
Third, enter
- typedef enum {
- Uireturnkeydefault,//default: Gray button, marked with return
- Uireturnkeygo,//blue button labeled Go
- Uireturnkeygoogle,//blue button labeled Google for search
- Uireturnkeyjoin,//blue button labeled Join
- Uireturnkeynext,//blue button labeled Next
- Uireturnkeyroute,//blue button labeled route
- Uireturnkeysearch,//blue button labeled Search
- Uireturnkeysend,//blue button labeled Send
- Uireturnkeyyahoo,//blue button labeled Yahoo! for searching
- Uireturnkeydone,//blue button labeled done
- Uireturnkeyemergencycall,//Emergency call button
- } Uireturnkeytype;
Usage Use cases:
Textview.returnkeytype=uireturnkeygo;
Four, automatic capitalization
- typedef ENUM {
- Uitextautocapitalizationtypenone,//not automatically capitalized
- Uitextautocapitalizationtypewords,//capitalize the first letter of the word
- Uitextautocapitalizationtypesentences,//capitalize the first letter of the sentence
- Uitextautocapitalizationtypeallcharacters,//All letters capitalized
- } Uitextautocapitalizationtype;
Usage Use cases:
Textfield.autocapitalizationtype = Uitextautocapitalizationtypewords ;
Five, automatic correction
- typedef ENUM {
- uitextautocorrectiontypedefault,//Default
- uitextautocorrectiontypeno,//does not automatically correct
- uitextautocorrectiontypeyes,//Auto Correction
- } Uitextautocorrectiontype;
Usage Use cases:
Textfield.autocorrectiontype = Uitextautocorrectiontypeyes;
Six, secure text input
Textview.securetextentry=yes;
Turning on secure input is primarily for passwords or some private data input, which disables AutoCorrect and self-caching.
Statistic character and response return key
Statistical characters:
1, Uitextview
-(void) Textviewdidchange: (Uitextview *) textview{ int count = [Textview.text length]; Count here is the number of characters}
2, Uitextfield
Method One:
Add a response method for Uitextfield's editing changed event first
-(Ibaction) Valuechange//m_textfield is a iboutlet{ int count = [M_textfield.text length] of Uitextfield; Count is the current number of characters //The bottom is to limit the characters within 140 if ([M_textfield.text length]>140) { [M_textfield settext:[m_ Textfield.text substringtoindex:140]];//140, fetch only the first 140 characters }}
Method Two:
In the Proxy method:-(BOOL) TextField: (Uitextfield *) Textfieldshouldchangecharactersinrange: (Nsrange) Rangereplacementstring: (nsstring*) string, judging the value of range.length to determine whether the input is a back lattice or other characters
Response Return key :
1, Uitextview
Proxy method
-(BOOL) TextView: (Uitextview *) TextView Shouldchangetextinrange: (nsrange) Range Replacementtext: (NSString *) text{ if (1 = = Range.length) {//press the next SPACEBAR to return YES; } if ([text isequaltostring:@ "\ n"]) {//press the RETURN key// hide the keyboard here, do not do any processing [TextView Resignfirstresponder]; return NO; } else { if ([Textview.text length] < 140) {//To determine the number of characters return YES;} } return NO;}
2, Uitextfield
This is a direct proxy method, huh?
-(BOOL) Textfieldshouldreturn: (Uitextfield *) TextField
Uitextfield Enter edit state to get focus Becomefirstresponder
Turn off keyboard resignfirstresponder