1, keyboard style
the Uikit Framework supports 8 styles of keyboards.
typedef enum {
Uikeyboardtypedefault,//default keyboard: supports all characters
Uikeyboardtypeasciicapable,//support for ASCII default keyboard
Uikeyboardtypenumbersandpunctuation,//Standard telephone keypad, support +* #等符号
Uikeyboardtypeurl,//URL keyboard, with. com button; URL characters only supported
Uikeyboardtypenumberpad,//numeric keypad
Uikeyboardtypephonepad,//Telephone keypad
Uikeyboardtypenamephonepad,//telephone keypad, also support input person name
Uikeyboardtypeemailaddress,//keyboard for entering email address
} Uikeyboardtype;
Usage use case:
Textview.keyboardtype = Uikeyboardtypenumberpad;
2, the appearance of the keyboard
typedef enum {
Uikeyboardappearancedefault,//default appearance: Light Gray
Uikeyboardappearancealert,//dark gray/graphite
} uikeyboardappearance;
Usage use case:
Textview.keyboardappearance=uikeyboardappearancedefault;
3, enter
typedef enum {
Uireturnkeydefault,//default: Gray button, marked return
Uireturnkeygo,///marked with Go Blue button
Uireturnkeygoogle,//marked with Google's blue button for search
Uireturnkeyjoin,//blue button labeled Join
Uireturnkeynext,//blue button labeled Next
Uireturnkeyroute,///marked with route blue button
Uireturnkeysearch,//blue button labeled Search
Uireturnkeysend,//blue button marked with Send
Uireturnkeyyahoo,///marked with Yahoo! Blue button for search
Uireturnkeydone,//marked with the Done blue button
Uireturnkeyemergencycall,//Emergency call button
} Uireturnkeytype;
Usage use case:
Textview.returnkeytype=uireturnkeygo;
4, automatic capitalization
typedef enum {
Uitextautocapitalizationtypenone,//Do not automatically capitalize
Uitextautocapitalizationtypewords,//Word First Letter Capital
Uitextautocapitalizationtypesentences,//sentence first letter capital
Uitextautocapitalizationtypeallcharacters,//all uppercase letters
} Uitextautocapitalizationtype;
Usage use case:
Textfield.autocapitalizationtype = Uitextautocapitalizationtypewords;
5. Automatic corrections
typedef enum {
uitextautocorrectiontypedefault,//Default
uitextautocorrectiontypeno,//does not automatically correct
uitextautocorrectiontypeyes,//Automatic corrections
} Uitextautocorrectiontype;
Usage use case:
Textfield.autocorrectiontype = Uitextautocorrectiontypeyes;
6, secure text input
Textview.securetextentry=yes;
Turning on security input is primarily for passwords or some personal data input, which disables AutoCorrect and caching from this point.
7, open the keyboard to cover view problem solving method
By default, opening the keyboard will obscure the view below, causing a little trouble, but this is not a big problem, we can use a little bit of means to solve.
First we need to know the keyboard height is fixed, but in iOS 5.0 after the height of the keyboard seems not 216, but it does not matter, we adjust the adjustment is:
The approach we took was to move the Self.view overall up 216px (we took the iphone vertical screen for example) when TextField (possibly other controls) received a pop-up keyboard event.
First we want to set the TextField agent, we are set as the current controller.
Then we implement the following three delegate methods on the current controller:
-(void) textfielddidbeginediting: (Uitextfield *) TextField
{//When the touch TextField inside, start editing will call this method. TextField will become the responder
Nstimeinterval animationduration = 0.30f;
CGRect frame = self.view.frame;
FRAME.ORIGIN.Y-=216;
Frame.size.height +=216;
Self.view.frame = frame;
[UIView beginanimations:@ "Resizeview" context:nil];
[UIView setanimationduration:animationduration];
Self.view.frame = frame;
[UIView commitanimations];
}
-(BOOL) Textfieldshouldreturn: (Uitextfield *) TextField
{//When the user presses the Ruturn and moves the focus away from the TextField, the keyboard disappears.
Nstimeinterval animationduration = 0.30f;
CGRect frame = self.view.frame;
FRAME.ORIGIN.Y +=216;
frame.size. Height-=216;
Self.view.frame = frame;
Self.view move back to the original location
[UIView beginanimations:@ "Resizeview" context:nil];
[UIView setanimationduration:animationduration];
Self.view.frame = frame;
[UIView commitanimations];
[TextField Resignfirstresponder];
}