IOS_UITextField basic operations

Source: Internet
Author: User

IOS_UITextField basic operations
Basic operations

UITextField * userNameTextField = [[UITextField alloc] init]; userNameTextField. frame = CGRectMake (30,100,220, 50); [self. window addSubview: userNameTextField]; [userNameTextField release]; // set the style userNameTextField. borderStyle = UITextBorderStyleRoundedRect; userNameTextField. placeholder = @ "Enter your name"; userNameTextField. text = @ "OUTLAN"; userNameTextField. clearButtonMode = UITextFieldViewModeWhileEditing; // you can specify the time when UILabel * leftLable = [[UILabel alloc] initWithFrame: CGRectMake (0, 0, 20, 20)]; leftLable. text = @ "N"; // set the display time of the left and right views userNameTextField. leftView = leftLable; userNameTextField. leftViewMode = UITextFieldViewModeAlways; [leftLable release]; userNameTextField. enabled = YES; // set whether to allow the input of userNameTextField. clearsOnBeginEditing = NO; // empty userNameTextField during input. secureTextEntry = NO; // displays dots, which are generally used to enter the password userNameTextField. keyboardAppearance = UIKeyboardAppearanceDark; // The keyboard color is black userNameTextField. keyboardType = UIKeyboardTypeEmailAddress; // set the keyboard style userNameTextField. returnKeyType = UIReturnKeySearch; // set the return key style UIView * keyBoard = [[UIView alloc] initWithFrame: CGRectMake (0, 0, 0,300)]; keyBoard. backgroundColor = [UIColor greenColor]; // userNameTextField. inputView = keyBoard; // Replace the keyBoard [keyBoard release]; UIView * inputAccessView = [[UIView alloc] initWithFrame: CGRectMake (0, 0, 0, 20)]; inputAccessView. backgroundColor = [UIColor yellowColor]; userNameTextField. inputAccessoryView = inputAccessView; // secondary entry [inputAccessView release];
Revoking the keyboard setting proxy object, usually self
// Sets the proxy textFiled. delegate = self;
Current class Compliance Agreement
@interface AppDelegate : UIResponder 
  
Implementation Protocol
-(BOOL) textFieldShouldReturn :( UITextField *) textField {NSLog (@ "Click Return"); [textField resignFirstResponder]; // discard the first responder and reclaim the keyboard return YES ;} -(BOOL) textFieldShouldBeginEditing :( UITextField *) textField {NSLog (@ "ining"); return YES;}-(BOOL) textFieldShouldEndEditing :( UITextField *) textField {NSLog (@ "ending"); return YES ;}

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.