Summary of Uikeyboard keyboard view usage in IOS _ios

Source: Internet
Author: User


1, keyboard style
the Uikit Framework supports 8 styles of keyboards.


code as follows:

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:
 code as follows:

Textview.keyboardtype = Uikeyboardtypenumberpad;

2, the appearance of the keyboard
 code as follows:

typedef enum {
Uikeyboardappearancedefault,//default appearance: Light Gray
Uikeyboardappearancealert,//dark gray/graphite
} uikeyboardappearance;

Usage use case:
 code as follows:

Textview.keyboardappearance=uikeyboardappearancedefault;

3, enter
 code as follows:

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:
 code as follows:

Textview.returnkeytype=uireturnkeygo;

4, automatic capitalization
 code as follows:

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:
 code as follows:

Textfield.autocapitalizationtype = Uitextautocapitalizationtypewords;

5. Automatic corrections
 code as follows:

typedef enum {
uitextautocorrectiontypedefault,//Default
uitextautocorrectiontypeno,//does not automatically correct
uitextautocorrectiontypeyes,//Automatic corrections
} Uitextautocorrectiontype;

Usage use case:
code as follows:

Textfield.autocorrectiontype = Uitextautocorrectiontypeyes;

6, secure text input
 code as follows:

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.
 code as follows:

textfield,delegate=self;

Then we implement the following three delegate methods on the current controller:
 code as follows:

-(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];
}

 code as follows:

-(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];
}




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.