Basic operations
Uitextfield *usernametextfield = [[Uitextfield alloc] init]; Usernametextfield. Frame= CGRectMake ( -, -, -, -); [ Self. WindowAddsubview:usernametextfield]; [Usernametextfield release];//Set styleUsernametextfield. BorderStyle= Uitextborderstyleroundedrect; Usernametextfield. Placeholder= @"Enter Your Name"; Usernametextfield. Text= @"Outlan"; Usernametextfield. Clearbuttonmode= uitextfieldviewmodewhileediting;//Set Right Delete button appears time UILabel*leftlable = [[UILabelAlloc] Initwithframe:cgrectmake (0,0, -, -)]; Leftlable. Text= @"N";//Set display time for left and right viewUsernametextfield. Leftview= leftlable; Usernametextfield. Leftviewmode= Uitextfieldviewmodealways; [Leftlable release]; Usernametextfield. Enabled=YES;//Set whether to allow inputUsernametextfield. clearsonbeginediting=NO;//empty at inputUsernametextfield. Securetextentry=NO;//Render dots, commonly used to enter passwordsUsernametextfield. Keyboardappearance= Uikeyboardappearancedark;//Control keyboard color is blackUsernametextfield. Keyboardtype= Uikeyboardtypeemailaddress;//Set keyboard styleUsernametextfield. Returnkeytype= Uireturnkeysearch;//Set the return button style UIView*keyboard = [[UIViewAlloc] Initwithframe:cgrectmake (0,0,0, -)]; KeyBoard. BackgroundColor= [UicolorGreencolor];//Usernametextfield.inputview = KeyBoard;//Replace keyboard[KeyBoard release];UIView*inputaccessview = [[UIViewAlloc] Initwithframe:cgrectmake (0,0,0, -)]; Inputaccessview. BackgroundColor= [UicolorYellowcolor]; Usernametextfield. Inputaccessoryview= Inputaccessview;//Auxiliary strips[Inputaccessview release];
Retract the keyboard settings proxy object, usually self
// 设置代理 textFiled.delegateself;
Current Class Compliance Protocol
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITextFieldDelegate>
Implementing Protocol Methods
-(bool ) Textfieldshouldreturn: (Uitextfield *) textfield{nslog (@ "click return" ); [TextField Resignfirstresponder]; //give up first responder retract keyboard return yes ;} -(bool ) textfieldshouldbeginediting: (Uitextfield *) textfield{nslog (@); return yes ;} -(bool ) textfieldshouldendediting: (Uitextfield *) textfield{nslog (@); return yes ;}
Ios_uitextfield Basic Operations