Weekly essays-15.10.27 and essay-15.10.27

Source: Internet
Author: User

Weekly essays-15.10.27 and essay-15.10.27
New knowledge point record for one week (15.10.27) I. Irregular button OBShapedButton

The regular button is a rectangle area. Even if the cornerradous of the button layer is set, the entire rectangle area can respond to the click event.

OBShapedButton is an open-source third-party library that is directly inherited from UIButton and can be directly used. Its response area is limited to the image or background image area of the button, and the blank area cannot respond.

II, SendActionsForControlEvents

UIButton instance method. You can use the code to manually send the response method of clicking the event trigger button.

Iii. Time Zone Related to ios time

All obtained NSDate in the Code is UTC time (International Standard Time, same as GMT time). For example, if you print [NSDate date], the printed result will always be UTC time, regardless of how the time zone of the device changes.

So does it take some time to process the time zone? For example, if the background returns a time string and I want to change its format, we need to first obtain the date of the time string and then reset the format to get the new time string. Previously, all dates are UTC time. Therefore, if you print the Date in the middle, you will find that the time is eight hours slower than the current one (assuming that the current system time zone is East 8 ), if we use this time to generate a new string, will the result be 8 hours slower? The answer is no. Because the time format NSDateFormatter has the timezone attribute, the default value of this attribute is the current system time zone, so when you convert from dete to string, when the system automatically adds the system time zone deviation to the UTC time during calculation, it is still the original time and will not be slowed down by 8 hours. In addition, the timezone value of dateFormatter is also used for eight hours of slow date.

In addition to NSDateFormatter, the calendar class NSCalendar also has the timeZone attribute. Assume that the dateComponents corresponding to the date is obtained, and the time displayed for viewing the date is 8 hours slower, while the time displayed for viewing the dateComponents is not 8 hours slower. The printed result is the current hour. Because the NSCalendar object needs to be used for date-> dateComponents, and calendar also has a timeZone attribute, which is also the current system time zone by default. The time zone deviation hours (Time Difference) will be automatically added during the conversion process ).

Therefore, there is usually no need to deal with unnecessary time zone issues.

4. Warnings about present popoverController

If the display of the current view controller is that the view of the add view Controller is in a view of the upper-level view controller, instead of being pushed to the UInavagationController or in the UITabbarController container, that is to say, this controller is not in the current app stack. Then, another view controller or popover from this view controller Presenting view controllers on detached view controllers will be warned!

 

5. Use UITableView + FDTemplateLayoutCell to automatically calculate the Cell height

Previously, the Cell height was calculated based on the Cell content space to calculate the height one by one and then sum up to get a definite value. In this way, when the number of controls is large, or a label-like control that needs to adapt the height according to the text length, when calculating the label height, you must also calculate the text height. What a headache! With UITableView + FDTemplateLayoutCell, cell height computing is much easier!

UITableView + FDTemplateLayoutCell solves the cell height calculation problem in one sentence.

In the heightForRowAtIndexPath proxy method, write

Return [tableView fd_heightForCellWithIdentifier: @ "identifierMyCell" cacheByIndexPath: indexPath configuration: ^ (id cell) {// The variable content configuration of the cell, such as the text of the label, is used to determine the height}];

In this way, tableView automatically calculates the height based on cell autoLayout.

Therefore, the premise of using this method is that the automatic layout of the cell content control must be accurate. It can be automatically deployed in IB or in plain code. I am used to using Masonry code layout.

6. Determine whether the app is used for the first time

[[NSUserDefaults standardUserDefaults] boolForKey: @ "firstStart"] can be used to determine whether the app is used for the first time.

NO before the first start, and YES after the start

 

VII, About UINavagationController And UItabBarController Of View Add view on

If you directly add a view myView to the UINavagationController. view or UItabBarController. view, after a viewController is pushed to the former, the myView will not be overwritten and will still be displayed in the front of the screen. For the latter, after switching to viewController, myView is also displayed in the old place.

 

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.