</pre><pre name= "code" class= "OBJC" > #import "ViewController.h"//Signed Proxy agreement @interface Viewcontroller () < Uitextfielddelegate> @end @implementation viewcontroller-(void) viewdidload {[Super viewdidload]; Note: Uitextfield inherits from Uicontrol, and Uitextview inherits from Uiscrollview,uiscrollview and inherits from UIView//Create input box Uitextfield *textfield = [[Uitextfield Alloc] Initwithframe:cgrectmake (20, 50, 280, 100)]; Sets the border style of the input box Textfield.borderstyle = Uitextborderstyleroundedrect; Sets the current object as the input box for the proxy textfield.delegate = self; The Delete button on the right textfield.clearbuttonmode = uitextfieldviewmodealways; Add to Current View [Self.view Addsubview:textfield]; Because Uitextfield inherits from Uicontrol, you can do the following, which can be used to control the length of text in the input box and the input limit [TextField addtarget:self action: @selector (pick) Forcontrolevents:uicontroleventeditingchanged];} -(void) pick{NSLog (@ "text content changed");} #pragma mark-uitextfielddelegate//allow the input box to be edited-(BOOL) textfieldshouldbeginediting: (Uitextfield *) textfield{//return Yes indicates that you can edit and return no indicates that you cannot return YES;} became first responder (becomes the primary responder, display keyboard)-(void) textfielddidbeginediting: (Uitextfield *) textfield{//Once the method for editing the response is changed}// Return yes to allow to stop editing and to close the keyboard, return no means stop editing-(BOOL) textfieldshouldendediting: (Uitextfield *) textfield{return YES;} -(void) textfielddidendediting: (Uitextfield *) textfield{//Once the method of editing the response is ended}//This method is called when the content changes, restricting the length of the text within the input box-(BOOL) TextField: (Uitextfield *) TextField Shouldchangecharactersinrange: (nsrange) Range replacementstring: (NSString *) string{////Limit the length of text within the input box, the length of the text does not increase when the length is greater than or equal to 10, and cannot be deleted if (TextField.text.length >=) {return NO; }else{return YES; }}//when the Delete button exists, use this method to control whether the button is valid, which can be deleted by default-(BOOL) Textfieldshouldclear: (Uitextfield *) textfield{return NO;} Click Return Response Event-(BOOL) Textfieldshouldreturn: (Uitextfield *) textfield{//Logout First responder, close keyboard [TextField resignfirstrespon Der]; return YES;} @end
< Span style= "" > development, uitextfield The use of frequency or relatively high, such as the general account login, etc. are used to uitextfield uitextfield
Welcome to join QQ Group Name: IOS Coterie Group number:177204933; progress and growth along the path of IOS development.
iOS UI Learning-uitextfield Agent