Zero-based IOS8 programming "keyboard Action"

Source: Internet
Author: User
Tags uicontrol

Shimen the main contribution, respect the work of the author, please do not reprint.

If the article is helpful to you, you are welcome to donate to the author, support the Shimen, donate the amount at random, ^_^

I want to donate: Click Donate

Cocos2d-x source Download: Dot I teleport



keyboard input
,  keyboard input processing more trouble After the input is complete we need to close the keyboard in the iphone we can also specify the keyboard input type ,  Phone and number types
Enter finish to close the keyboard
After you enter the text box , the keyboard is not closed and you must write code .

modify file
add event handling method for off keyboard :
h file
-(ibaction) textfielddoneediting: (ID) sender;
m file
-(ibaction) textFieldDoneEditing: ( ID) Sender {
[sender resignfirstresponder];
}

Link Events
The Do End on Exit event of the text box object is linked to file ' Owner.

iOS keyboard summary Click on" line "  or "return" key to turn off the keyboard First responder is the control currently interacting with the user ,  in this case ,  click TextField control ,  it becomes The first responder keyboard will automatically appear [sender resignFirstResponder];


,
We can close the keyboard by touching the background add action declaration hello-.h :
-( ibaction) Backgroundtap: (ID) sender;
add action in HELLO-.M file :
-(ibaction) Backgroundtap: (ID) sender {
[txtfield Resignfirstresponder];

/span>
Connect actions and Events
In order for the background control to respond to events , We need the parent class of the background view (UIView) to be modified to be uicontrol,
Uicontrol is a subclass that can trigger an actionand all controls are uicontrol. and Uicontrol is the UIView subclass, also has the view basic characteristic.


drag from the touch down event to the file's owner icon and select Backgroundtap: action. In this way, you can trigger Backgroundtap: action and close the keyboard anywhere in the touch view where there are no active controls.


Keyboard input type
In the iphone we can also specify the type of keyboard input, which can be email, phone, and number types.


Email keyboard

Numeric keypad

Telephone keypad


Return key Setting
in the keyboard input properties box We can define return Key, we can have Google and so on. but these do not actually mean that it can trigger the input completion event (did End OnExit).

Shimen the main contribution, respect the work of the author, please do not reprint.

If the article is helpful to you, you are welcome to donate to the author, support the Shimen, donate the amount at random, ^_^

I want to donate: Click Donate

Cocos2d-x source Download: Dot I teleport


Zero-based IOS8 programming "keyboard Action"

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.