iOS keyboard Related settings (Uitextfield)

Source: Internet
Author: User

http://blog.csdn.net/h3c4lenovo/article/details/8447661

First, the keyboard style

The Uikit Framework supports 8 styles of keyboards.

  1. typedef ENUM {
  2. Uikeyboardtypedefault,//default keyboard: All characters supported
  3. Uikeyboardtypeasciicapable,//ASCII-enabled default keyboard
  4. Uikeyboardtypenumbersandpunctuation,//Standard telephone keypad, supports +* #等符号
  5. Uikeyboardtypeurl,//URL keyboard with. com button; URL characters only
  6. Uikeyboardtypenumberpad,//numeric keypad
  7. Uikeyboardtypephonepad,//Telephone keypad
  8. Uikeyboardtypenamephonepad,//telephone keypad, also support input person name
  9. Uikeyboardtypeemailaddress,//keyboard for entering e-mail addresses
  10. } Uikeyboardtype;

Usage Use cases:

Textview.keyboardtype= Uikeyboardtypenumberpad;

Second, keyboard appearance

    1. typedef ENUM {
    2. Uikeyboardappearancedefault,//default appearance: Light grey
    3. Uikeyboardappearancealert,//dark grey/Graphite
    4. } uikeyboardappearance;

Usage Use cases:

Textview.keyboardappearance=uikeyboardappearancedefault;

Third, enter

  1. typedef enum  {  
  2. Uireturnkeydefault,//default: Gray button, marked with return
  3. Uireturnkeygo,//blue button labeled Go
  4. Uireturnkeygoogle,//blue button labeled Google for search
  5. Uireturnkeyjoin,//blue button labeled Join
  6. Uireturnkeynext,//blue button labeled Next
  7. Uireturnkeyroute,//blue button labeled route
  8. Uireturnkeysearch,//blue button labeled Search
  9. Uireturnkeysend,//blue button labeled Send
  10. Uireturnkeyyahoo,//blue button labeled Yahoo! for searching
  11. Uireturnkeydone,//blue button labeled done
  12. Uireturnkeyemergencycall,//Emergency call button
  13. } Uireturnkeytype;

Usage Use cases:

Textview.returnkeytype=uireturnkeygo;

Four, automatic capitalization

    1. typedef ENUM {
    2. Uitextautocapitalizationtypenone,//not automatically capitalized
    3. Uitextautocapitalizationtypewords,//capitalize the first letter of the word
    4. Uitextautocapitalizationtypesentences,//capitalize the first letter of the sentence
    5. Uitextautocapitalizationtypeallcharacters,//All letters capitalized
    6. } Uitextautocapitalizationtype;

Usage Use cases:

Textfield.autocapitalizationtype  =  Uitextautocapitalizationtypewords ;

Five, automatic correction

    1. typedef ENUM {
    2. uitextautocorrectiontypedefault,//Default
    3. uitextautocorrectiontypeno,//does not automatically correct
    4. uitextautocorrectiontypeyes,//Auto Correction
    5. } 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

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.