A week of new knowledge Point Records (15.10.19)I.
Ipad--uipopovercontroller
Uipopovercontroller inherits from NSObject and therefore does not have the ability to display, it is the content that is displayed through the content controller.
The Uipopovercontroller uses four of the music:
First, create a content controller for Uipopovercontroller
Ii. Initialize the Uipopovercontroller object based on the content controller
Third, set the size of the Uipopovercontroller object
Iv. displaying Uipopovercontroller objects
There are two ways to display Uipopovercontroller objects:
Method One: Display by clicking the Uibarbuttonitem button
-(void) Presentpopoverfrombarbuttonitem: (Uibarbuttonitem *) Item Permittedarrowdirections: ( Uipopoverarrowdirection) arrowdirections animated: (BOOL) animated;
Parameter description:
Item: Trigger the displayed Uibarbuttonitem object
Arrowdirections: Direction of arrows displayed
Animated: whether to show transition animations
Method Two: Display the specific area
-(void) Presentpopoverfromrect: (cgrect) rect inview: (UIView *) View permittedarrowdirections: ( Uipopoverarrowdirection) arrowdirections animated: (BOOL) animated;
Parameter description:
Rect: The area that the arrow points to
View: Rect -corresponding views
Arrowdirections: Show the direction of the arrows
Animated: whether to show transition animations
Attention:
1, Uipopovercontroller object size is not recommended to write dead, should be based on the needs of the content controller. iOS7 previously set a value for the contentsizeforviewinpopover of the content controller (Uiviewcontroller) , iOS7 The value of the content controller's preferredcontentsize is set later.
2,Uipopovercontroller object display, the default any other control is not interactive, click Uipopovercontroller Object Area Unexpected part, Object dismiss. If you want to interact with a control when the Uipopovercontroller object is displayed, you can do so by setting the Passthroughviews property. It is an array object that copies the control that needs to be interactive to it.
two. Two-dimensional code generation
iOS7 later the system provides a filter method that generates a two-dimensional code in the Coreimage framework. third-party libraries supported by the C language Libqrencode are also a good choice. See Demo
three. Display mode and transition mode when displaying modal window
// display mode Vc.modalpresentationstyle = uimodalpresentationfullscreen; // transition mode vc.modaltransitionstyle = Uimodaltransitionstylepartialcurl;
For the iphone, consider only the transition mode.
For the ipad , both can be considered, the display method is more commonly used is Uimodalpresentationformsheet(occupy the middle of a small piece)
four. using UITableView in storyboard
You can set TableView's head view and tail view directly in storyboard, drag out TableView to IB, and then drag the view control to TableView as a child view ( TableView only allows two sub-views, head view and Tail view in IB, two views are attached, heads are at the top end. Only applicable with storyboard,xib not applicable, accustomed to use storyboard words can greatly improve the development efficiency .
You can also set up proxies and data sources directly in IB for TableView.
Five. How to set the
highly adaptive
options parameter
Nsstringdrawingtruncateslastvisibleline:
If the text content exceeds the specified rectangle limit, the text is truncated and an ellipsis is added to the last character. If the Nsstringdrawinguseslinefragmentorigin option is not specified , this option is ignored.
Nsstringdrawinguseslinefragmentorigin:
Use line Fragement origin instead of baseline origin when drawing text.
Nsstringdrawingusesfontleading:
Use line spacing when calculating row heights. (Translator Note: Font size + line spacing = leading)
Nsstringdrawingusesdevicemetrics:
Use primitive glyphs (not print fonts) when calculating layouts.
Test findings:
When using Nsstringdrawinguseslinefragmentorigin only, the width constraint is relied upon, even if the calculated height exceeds the set constraint height, the calculated height is returned, which is the constraint that ignores the height.
using nsstringdrawinguseslinefragmentorigin| Nsstringdrawingtruncateslastvisibleline, if the height of the calculation exceeds the height of the constraint, the final height returned is the height of the text corresponding to the maximum number of rows, such as the height of the constraint to accommodate 2 rows, no more than 3 rows , the size height returned is the height of 2 rows.
Summary usage:
The options parameter is used when calculating
nsstringdrawinguseslinefragmentorigin| nsstringdrawingtruncateslastvisibleline| Nsstringdrawingusesfontleading
You can also use Sizewithattributes to calculate single-line text directly
Six.
Topviewcontroller & visibleviewcontroller of navigation controller
Topviewcontroller represents the topmost VC in the current navigation stack, while VisibleviewcontrolleR represents the currently visible VC, which may be Topviewcontroller , or it may be the current Topviewcontroller present out of the VC. So the two properties of Uinavigationcontroller are usually the same, but they can be different.
Seven. Implementation of custom calendars
Calendar main interface through the CollectionView building, the difficulty is to get the calendar structure of the specified month, including the beginning of this month is a few days last month, the end of a few days is next month, the information is saved to the array by a different character ID, for example, * Indicates the last month's date,#表示下个月的date, which is identified by 1~ days in the middle of the month , gives the calendar structure for the specified month.
It is crucial to get an array of the calendar structure of the specified month for this entity, with its interface built on it. See Demo for details
It is worth mentioning that the first day of every week is Sunday. So if the calendar is 7 days in a row, the default leftmost is Sunday. If you want to change from left to right is the structure of Monday ~ Sunday, as long as the calendar object is set to the Firstweekday property value of 2,(default is 1, starting from Sunday ).
Eight. About the height of the string
A string, font size 15, calculated size, displayed as two lines, line spacing set to 3, print calculated height of 38.79.
Print font size 15 for each property of a Font object and view
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 (pre-set )
As you can see from the data:
(1) the calculated height ismade up of two lines of high (lineheight) and one row of line spacing (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), row height (lineheight = ascender-descender)
(3)xheight and capheight is not important, in particular, you can check the online glyph of the map, but that picture personally think there is a problem, and the actual test printed data does not match. leading is lineheight.
In addition, the test found that the text is set for line spacing
A line of text calculates the height result = text height + line spacing
Two lines of text calculate height result = text height *2+ line spacing
Three lines of text calculates height result = text height *3+ line spacing
Four lines ....
If the line spacing text is not set (the text default line spacing is 0), the text height is the row height * Number of rows
A week of essays--15.10.19