One-week Essays -- 15.10.19 and later -- 15.10.19

Source: Internet
Author: User

One-week Essays -- 15.10.19 and later -- 15.10.19
A new knowledge point record in a week (15.10.19) I.Ipad-UIPopoverController

UIPopoverController inherits from NSObject and therefore does not have the display capability. It displays content through the content controller.

UIPopoverController uses the following section:

1. Create a content controller for UIPopoverController

Ii. initialize the UIPopoverController object based on the Content Controller

3. Set the UIPopoverController object size

4. Display UIPopoverController objects

 There are two methods to display the UIPopoverController object:

Method 1: Click UIBarButtonItem.

- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;

Parameter description:

Item: The UIBarButtonItem object that triggers the display.

ArrowDirections: the direction of the displayed arrow

Animated: whether to display transition Animation

Method 2: display specific regions

- (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;

Parameter description:

Rect: Area pointed by the arrow

View: view corresponding to rect

ArrowDirections ctions: displays the direction of the arrow.

Animated: whether to display transition Animation

Note:

1. It is not recommended that the UIPopoverController object size be written to death. It should be based on the needs of the content controller. Ios7 previously sets a value for the contentSizeForViewInPopover of the content controller (UIViewController) and the preferredContentSize of the content Controller after ios7.

2. When the UIPopoverController object is displayed, no other controls can interact by default. Click the unexpected part of the UIPopoverController object area and the object dismiss. If you want to interact with a control when the UIPopoverController object is displayed, you can set the passthroughViews attribute. It is an array object. You can package the control that requires interaction into an array and copy it to it.

Ii. QR code generation

After ios7, the system provides a filter method for generating QR codes in the CoreImage framework. Libqrencode, a third-party Library Supported by C, is also a good choice. See Demo

Iii. Display Mode and transition mode when displaying the modal window
// Display mode vc. modalPresentationStyle = UIModalPresentationFullScreen; // transition mode vc. modalTransitionStyle = UIModalTransitionStylePartialCurl;

For the iphone, only the transition mode is considered.

Both of them can be considered for the ipad. The display method is usually UIModalPresentationFormSheet (occupying the middle part)

4. Use UITableView in storyboard

You can directly set the header and tail views of tableView In the storyboard, drag tableView to IB, drag the view control to tableView as the sub-view (tableView only allows two sub-views in IB, the first view and the last view. The two views are connected, and the first and last views are at the top and bottom ). It is applicable only to storyboard, and xib is not applicable. It can greatly improve the development efficiency if storyboard is used.

In addition, you can directly set the proxy and data source for tableView in IB.

5. Highly adaptive Options Parameters How to Set

NSStringDrawingTruncatesLastVisibleLine:

If the text content exceeds the limit of the specified rectangle, the text is truncated and the ellipsis is added after the last character. If the NSStringDrawingUsesLineFragmentOrigin option is not specified, this option is ignored.

NSStringDrawingUsesLineFragmentOrigin:

Use line fragement origin instead of baseline origin to draw text.

NSStringDrawingUsesFontLeading:

Use line spacing when the calculated rows are high. (Translator's note: font size + line spacing = line spacing)

NSStringDrawingUsesDeviceMetrics:

The layout is calculated using a metachiname rather than a printed font ).

Test found:

When NSStringDrawingUsesLineFragmentOrigin is used only, the width constraint is used as the dependency. Even if the calculated height exceeds the specified height, the calculated height is returned, that is, the height constraint is ignored.

When NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine is used, if the calculated height exceeds the constrained height, the final returned height is the height corresponding to the text that can hold the maximum number of lines. For example, the constraints can hold, if there are no more than three rows, the returned Size height is the height corresponding to the two rows.

Summary:

The options parameter is used during calculation.

NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesFontLeading

In addition, you can use sizeWithAttributes to calculate a single line of text.

6. Navigation Controller TopViewController & visibleViewController

TopViewControllerRepresents the top-most VC in the current navigation stack, andVisibleViewControlleR represents the currently visible VC, which may be the topViewController or the VC from the current topViewController present. Therefore, the two attributes of UINavigationController are usually the same, but they may also be different.

7. Implement custom calendar

The main interface of the calendar is set up through collectionView. The difficulty is to obtain the calendar structure of the specified month, including the calendar structure of the previous month for the first day of the month and the calendar for the last day of the next month, save the information to the array using different character identifiers. For example, * indicates the date of the previous month, # indicates the date of the next month, and 1 ~ The number of days to get the calendar structure of the specified month.

It is critical to obtain the array containing the specified monthly calendar structure. With the help of its interface, you can build a foundation. For details, see the Demo.

It is worth mentioning that the first day of each week is Sunday. Therefore, if the calendar is one row in seven days, the default leftmost is Sunday. If you want to change from left to right to Monday ~ For the structure of Sunday, you only need to set the FirstWeekday attribute value of the calendar Object calendar to 2 (the default value is 1, starting from Sunday ).

8. About the string height

A string with a font size of 15. The calculated size is displayed as two rows, the row spacing is set to 3, and the calculated height is 38.79.

Print and view the attributes of a font object with a font size of 15

Leading * 2 = 35.790000

LineHeight * 2 = 35.790000

CapHeight * 2 = 21.420000

XHeight * 2 = 15.510000

Ascender * 2 = 28.560000

Descender * 2 =-7.230000

LineSpacing = 3.000000 (set in advance) 

The data shows that:

(1) The calculated height is composed of lineHeight and lineSpacing.

(2) ascender is the distance from the text baseline to the top of the text, descender is the distance from the bottom of the text to the baseline (negative), and line height (lineHeight = ascender-descender)

(3) xHeight and capHeight are not important. You can view the graph on the Internet. However, this graph is considered problematic and does not match the data printed in the actual test. Leading is lineHeight.

In addition, the test shows that the line spacing text is set

Calculation height of one line of text = text height + line spacing

Calculation height of two lines of text = text height * 2 + line spacing

Calculation height of three lines of text = text height * 3 + line spacing * 2

Four rows ....

If no text line spacing is set (the text line spacing is 0 by default), the text height is the line height * number of lines

 

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.