*********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