Common development skills in iOS development

Source: Internet
Author: User

1. Close the keyboard after textfield is input.

By adding an event for textfield, The did end on exit event is triggered when the done button is clicked when the input is complete.

In the event Method body, you only need one sentence:

1-(Action) textfileddoneediting :( ID) sender {2 [Sender resignfirstresponder]; 3}

Do not forget to add this event for textfield through IB.

The above is for textfield pop-up Input Keyboard has a button. What if the keyboard limits only the number key?

According to Apple's consistent style, the keyboard is canceled by clicking a blank space. Without a doubt, this user experience is quite good. How can this problem be solved?

Our views are all based on a view. The default view is inherited from the uiview. Because this uiview is too abstract, we need more specific things to add events, oh, so let's make the bottom view inherit from uicontrol.

Needless to say, uicontrol is a subclass of uiview. So we can use IB to add events to our underlying view, just like adding events to general components. At this time, it is (touch down). Don't make a mistake. Describes how to modify the inheritance relationship of a view.

You can select View in IB and press the combined key command + 4. The first line of view identity is the class option. If you select uicontrol, it will be OK. How to Write events.

1-(ibaction) backgroundtap :( ID) sender {2 [namefiled resignfirstresponder]; 3 [numberfield resignfirstresponder]; 4}

I only have two input boxes in the entire view.

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.