After a long time, today I finally have time to summarize the pitfalls related to adapting to iPhone X. Generally speaking, there are two kinds of pitfalls. One is that the height of the navigation bar + status bar has changed, and the other is that some UITableViews that do not implement proxy methods such as -tableView: viewForHeaderInSection: and -tableView: viewForFooterInSection: will be misplaced. 1. Determine whether it is an iPhone X: Return YES or NO 1.1 Judgment: Macro (1) Based on screen resolution Trinocular algorithm
Multi-line logical judgment
Among them, the backslash \ is not a comment or other useless symbol, but a necessary symbol for multi-line macro line breaks. ***The sentence tmp;\ is also necessary, because the tmp obtained through logical judgment is used as the return value of the macro. (2) Based on screen size
1.2 Judgment: Method Method: According to the device model
2. Flexible return status bar + navigation bar height Requirement: Flexibly obtain the height of the navigation bar + status bar as the starting point of the Y axis of a subview. Macro Definition
Calling Example
3. Extension: Get iOS system and App version information Get iOS system version number: Returns a string
Get App version number: Returns a string
4. Other issues related to iPhone X adaptation In the process of adapting to iPhone X and Xcode 9, in addition to problems related to the navigation bar, another problem that often occurs is the problem related to UITableView. The following two methods can solve most of the misalignment problems. When VC creates tableView properties, set it like this
You can also set
About the safe area of the root view iOS has added a safeArea. In the old code, the code that specifies the relationship between the subview and the root subview needs to add a judgment: when iOS 11 is released, it needs to be changed to the relationship between the subview and the root subview's safe area. In this way, there will be no interference from any controls on the virtual home at the bottom of the iPhone X.
Of course, except for the tabbar, other views such as tableView or web page view can be placed in the bottom virtual home area. At this time, there is no need to emphasize that the subview must be placed in the safeArea, and the original old code does not need to be changed. |
<<: [Live] Technology or management, how should programmers plan their career path?
>>: After another year of tinkering, what is the dilemma facing WeChat Mini Programs?
According to media reports, on August 5, an astro...
There are some lines in the classic crosstalk &qu...
In 2019, optimizers, have you made good channel l...
Recently, many friends have had "opioid feve...
Recently in Jiangxi Province, a lucky angler succ...
Conversion is the key factor in paid promotion . ...
The birth of artificial intelligence has brought ...
The thyroid gland is the largest endocrine gland ...
One year after the 516 Entity List, Huawei did no...
The biggest puzzlement of a group of foreign bran...
Course Outline 1. Basics 1. Introduction to Xiaoh...
"Young Marshal, Your Wife Ran Away Again&quo...
2020 Wang Ruikuan Shen's Gynecology Tongue Di...
[[143282]] Preface: There is a saying in the entr...
Dynamically change application icons Product: Can...