iOS keyboard Click the ENTER key to what happened

Source: Internet
Author: User

#import   "ViewController.h" @interface  ViewController  ()  <uitextfielddelegate>@ property  (weak, nonatomic)  IBOutlet UITextField *usernameTextfield; @property   ( weak, nonatomic)  IBOutlet UITextField *passwordTextfield; @property   (weak,  nonatomic)  IBOutlet UIButton *loginBtn; @end @implementation viewcontroller-  (void) Viewdidload {    [super viewdidload];    // do any  additional setup after loading the view, typically from a  nib.        //setting Usernametextfield and Passwordtextfield related properties          //setting  usernameTextfield  keyboard type     /*      typedef ns_enum (Nsinteger, uikeyboardtype)  {      uikeyboardtypedefault,                 // default type  for the current input method.      Uikeyboardtypeasciicapable,           // displays  a keyboard which can enter ascii characters, non-ascii keyboards  remain active     UIKeyboardTypeNumbersAndPunctuation,  //  numbers and assorted punctuation.     uikeyboardtypeurl,                     //  A type optimized for URL entry  (shows . / .com  prominently) .     uikeyboardtypenumberpad,               //&nBsp a number pad  (0-9) . suitable for pin entry.      uikeyboardtypephonepad,                // A phone pad  (1-9, *, 0, #, with letters under  The numbers) .     uikeyboardtypenamephonepad,            // A type optimized for entering a  Person ' s name or phone number.     uikeyboardtypeemailaddress,            // a type optimized for  multiple email address entry  (shows space @ . prominently).      uikeyboardtypedecimalpad ns_enum_available_ios (4_1),    //  a number pad&nbsP;with a decimal point.     uikeyboardtypetwitter ns_enum_ Available_ios (5_0),      // a type optimized for  twitter text entry  (easy access to @ #)       Uikeyboardtypewebsearch ns_enum_available_ios (7_0),    // a default  keyboard type with url-oriented addition  (shows space . prominently).           UIKeyboardTypeAlphabet =  uikeyboardtypeasciicapable, // deprecated           };     */        // self.usernametextfield.keyboardtype = uikeyboardtypenumberpad;         //Setting the  returnkey    s of Usernametextfieldelf.usernametextfield.returnkeytype = uireturnkeynext;         //You must allow this class to support the protocol before setting up the agent, and set the proxy to itself     self.usernameTextfield.delegate = self;             //Settings  usernameTextfield     self.passwordTextfield.keyboardType = UIKeyboardTypeEmailAddress;     self.passwordTextfield.returnKeyType = UIReturnKeyDone;     self.passwordtextfield.delegate =self;        //makes the password you enter into a small origin. and general applications are doing so     self.passwordTextfield.secureTextEntry = YES;     }-  (void) didreceivememorywarning {    [super didreceivememorywarning] ;    // dispose of any resources that can be  Recreated.} -  (ibaction) clickloginbtn: (Uibutton *) Sender {    nslog (@ "Login successful");} #pragma  mark - UITextFieldDelegate-  (BOOL) Textfieldshouldreturn: (uitextfield *) textfield{    if  (Textfield == self.usernametextfield)  {         //self.usernametextfield abandons the first responder, while Self.passwordtextfield becomes the first responder          [self.usernameTextfield resignFirstResponder];         [self.passwordtextfield becomefirstresponder];    }  else if (Textfield == self.passwordtextfield)  {         //self.passwordtextfield discards the first responder and calls the login function         [ self.passwordtextfield resignfirstresponder];        [ Self.loginbtn sendactionsforcontrolevents:uicontroleventtouchupinside];        //[self clickloginbtn:self.loginbtn];    }     return yes;} @end

What happens when you click the ENTER key on the iOS keyboard

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.