Form keyboard occlusion, modifying Uipickerview content Styles

Source: Internet
Author: User

1. Form keyboard occlusion

The application scenario for a CollectionView has multiple TextField, TextView for the user to fill in the information.

Before the entry of fewer entries, the method is more rough,Didselectitematindexpath, note the Collectionviewcell distance from the bottom of the screen, and then compare with the keyboard height, According to the actual situation to adjust the CollectionView contentoffset, but when the input of the method is not enough, you need to calculate more collectionviewcell distance from the bottom of the screen, error prone.

(1) write down the indexpath when selecting the input item, convenient for subsequent CollectionView sliding operation

It is important to note that the userinteractionenabled of the Collectionviewcell TextField and TextView are set to No and become the first responder when the user is selected.

(2) Get the keyboard height, adjust the CollectionView according to the height of the keyboard, and slide to the location of the target cel

(3) When the keyboard is hidden, restore the initial constraint of Collectonview

2. Floating-point price format display

There is an application scenario where the price is displayed exactly to 2 decimal places, and the decimal point is 0. For example, 99.00 display is 99, 99.90 is displayed as 99.9 yuan, directly using NSString stringWithFormat method to convert the decimal part of the display is not meet the requirements, first get a string containing 2 decimal places, and then special processing can be the fractional part of 0 removed,:

reference:IOS floating-point number minus 0.00 after decimal point and price format display

3. Modify the Uipickerview content style

When using Uipickerview, the default display of content may not meet the requirements, often need to modify its content style, such as text size, etc., Uipickerview itself is to provide such a proxy method for us to customize

Form keyboard occlusion, modifying Uipickerview content Styles

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.