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