iOS fifth day (2: User login, enter the Listener (proxy mode uitextfielddelegate)) and turn off the keyboard

Source: Internet
Author: User

*********User Login, enter the Listener (proxy mode uitextfielddelegate)#import "HMViewController.h"@interfaceHmviewcontroller () <UITextFieldDelegate>@property (Weak, nonatomic) Iboutlet Uitextfield*Usernametext, @property (weak, nonatomic) Iboutlet Uitextfield*Pwdtext;@end@implementationHmviewcontroller- (void) viewdidload{[Super Viewdidload]; [Self.usernametext Becomefirstresponder];}-(ibaction) login{NSLog (@"%s%@%@", __func__, Self.userNameText.text, Self.pwdText.text);}#pragmaMark text Box Proxy method//handling of press Enter in the text box-(BOOL) Textfieldshouldreturn: (Uitextfield *) textfield{NSLog (@"%@", TextField); //If the cursor is in the user name, switch to password    if(TextField = =self.usernametext) {//The password becomes the first responder[Self.pwdtext Becomefirstresponder]; } Else if(TextField = =self.pwdtext) {//the input focus is in the Password box//If it is a password, call the login method directly[self login]; //turn off the keyboard//[Self.view Endediting:yes]; //Let the password text box close the keyboard//[TextField Resignfirstresponder];[Self.pwdtext Resignfirstresponder]; }        returnYES;}@end

iOS fifth day (2: User logon, carriage return Listener (proxy mode uitextfielddelegate)) and off keyboard

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: 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.