An < in the IOS keyboard protocol Uitextfielddelegate>

Source: Internet
Author: User

1. After setting the first responder of the keyboard, you can click TextField to summon the keyboard

The first responder method for setting the keyboard is:

[TextField Becomefirstresponder]; //At this time, the TextField input box is the first responder of the current keyboard, so only TextField lose the first responder, the keyboard will disappear

The method for setting the keyboard to lose the first responder is:

[TextField Resignfirstresponder]; //generally in the corresponding event of setting the Click button, or in the UIView click Trigger Event (at which point the screen can be answered wherever it is clicked)


2. If a QQ account input box, and a password input box and login button

When you click on the QQ input box, the keyboard responds, set the keyboard to the bottom right button is next, click Next after the keyboard first responder into the password input box, this time the keyboard right button to do, click the keyboard disappears

A. First set the corresponding QQ input box in the lower right corner button is next, the code is:

[_textfield_qq setreturnkeytype: Uireturnkeynext];

Then set the password input box to the bottom right button is done and the code is:

[_textfield_password setreturnkeytype:uireturnkeydone ];


B. Add the <UITextFieldDelegate> protocol to the. h file in TextField, and return to the. m file with the return key method such as the following:

-(BOOL) Textfieldshouldreturn: (uitextfield *) TextField {

if (TextField = = _textfield_qq) {// _textfield_qq and _textfield_password have been set as attributes to infer the first responder of the keyboard, assuming that the QQ input box

return [_textfield_passwordbecomefirstresponder]; Click Nextbutton in the lower right corner to set the first responder to _textfield_password, which is the Password entry box

}Else{

return [_textfield_passwordresignfirstresponder]; ///Otherwise (the first responder of the keyboard is the password input box), which causes the keyboard to lose its first responder, which disappears

}

}




An &lt; in the IOS keyboard protocol uitextfielddelegate&gt;

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.