4. IOS Programming uitextfiled

Source: Internet
Author: User

In front of the button, then let's see how uitextfield use.

Code: APPDDELEGATE.M

Define variable Uitextfield *textfield;-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (    Nsdictionary *) launchoptions {Self.window = [[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];    Self.window.backgroundColor = [Uicolor Whitecolor];    Uiviewcontroller *viewcontroller = [Uiviewcontroller alloc];    Self.window.rootViewController = Viewcontroller;    UIView *rootview = [[UIView alloc] initwithframe:[[uiscreen mainscreen] bounds]];        Viewcontroller.view = Rootview; /******************** Uitextfield ********************///create Uitextfield TextField = [[Uitextfield alloc] init]        ;        Set the position of the Uitextfield, width high textfield.frame = CGRectMake (100, 100, 200, 30); /** * Sets the border style with the following enumeration values: * Uitextborderstylenone (no format) * Uitextborderstyleline (lines) * Uitextborderstylebezel        (3D) * Uitextborderstyleroundedrect (fillet) */textfield.borderstyle = Uitextborderstyleroundedrect; Set the background color Textfield.backgrouNdcolor = [Uicolor Yellowcolor];        Set default input text//textfield.text = @ "text";        Set the prompt text Textfield.placeholder = @ "Jss";        Re-editing will automatically erase the original content textfield.clearsonbeginediting = YES;        The minimum value of the text//textfield.minimumfontsize = 10.0f;        Text automatically shrinks as the text box decreases textfield.adjustsfontsizetofitwidth = YES;      /** * Automatically converts the size of the text in the text box * Uitextautocapitalizationtypenone (do not toggle) * Uitextautocapitalizationtypewords (the first letter of each word) * Uitextautocapitalizationtypesentences (first letter of each sentence) * Uitextautocapitalizationtypeallcharacters (all letters) */t        Extfield.autocapitalizationtype = Uitextautocapitalizationtypewords; /** * Set Keyboard type * Uikeyboardtypedefault (default keyboard) * Uikeyboardtypeasciicapable (English alphabet keyboard) * Uikeyboardtypenumb Ersandpunctuation (Numeric and punctuation keyboard) * Uikeyboardtypeurl (URL keypad) * UIKEYBOARDTYPENUMBERPAD (numeric keypad) * Uikeyboardtypepho NEPAD (telephone dial keyboard) * UIKEYBOARDTYPENAMEPHONEPAD (personalized phone dial keypad) * Uikeyboardtypeemailaddress (enter e-mail addressKeyboard) * Uikeyboardtypedecimalpad (keyboard that can enter numbers and decimal points) * Uikeyboardtypetwitter (Twitter keyboard) * Uikeyboardtypewebsearch (        Web search Keyboard) */Textfield.keyboardtype = Uikeyboardtypenamephonepad; /** * Set Clear button type * Uitextfieldviewmodenever (never show Clear button) * Uitextfieldviewmodewhileediting (Show Clear button when editing) * UI Textfieldviewmodeunlessediting (Show Clear button except Edit) * uitextfieldviewmodealways (Clear button always appears) */Textfield.clearbuttonmod        e = uitextfieldviewmodewhileediting;        Add Uitextfield to view [Rootview Addsubview:textfield];    [Self.window makekeyandvisible]; return YES;} /** * Release keyboard */-(void) Touchesbegan: (Nsset *) touches withevent: (uievent *) event{[TextField Resignfirstresponder];}
Operation Result:

It is worth saying that the last paragraph of Touchesbegan: method. If you do not have this piece of code, then when you enter in the input box, the keyboard will not automatically collect it back. So, we want to get the current response and then turn off the keyboard. It is especially important to memorize it carefully.


The basic part, a brief introduction on the line, later encountered related to the other way to explain how to use.


Fourth Chapter, End!

This article is original, reproduced please specify the source, prohibited for commercial use. Thank you!

4. IOS Programming uitextfiled

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.