Compatible with ios11 and iphone x practices, and with ios11iphone

Source: Internet
Author: User

Compatible with ios11 and iphone x practices, and with ios11iphone

I. Adaptation to iOS11

Problem 1: There is a native interaction with H5 in the project. When running on iOS11, it directly crashes inside the framework WebViewJavascriptBridge.

Error message: Completion handler passed to-[WKWebViewJavascriptBridge webView: decidePolicyForNavigationAction: decisionHandler:] was called more than once

Solution: At that time, I was sure to immediately check the issue of the framework on github and found the solution. Link to this issue: https://github.com/marcuswestin/webview?criptbridge/issues/302,details

 

Just modify the solution according to the solution provided above. It is compared with the modification before the modification (before the modification on the left and after the modification on the right)

 

 

Question 2: when the user first installs the tool, the "Find permission" dialog box does not pop up?

Solution: the original permission request in ios 11 was downgraded because the method used to request the positioning permission for the first time in the project was requestAlwaysAuthorization, but requestWhenInUseAuthorizationf should be used in ios11.

 

Problem 3: In ios11, the interval between tableView groups increases.

Solution: The heightForFooterInSection method is implemented before the Group tail spacing, but the viewForFooterInSection method is not implemented. It is okay before ios11, but it should be implemented now, if you don't need them to have spacing, you need to set it like this.

 

Question 4: The contentInsetAdjustmentBehavior attribute added by tableView or scrollView in ios11

Solution: see my previous blog http://www.cnblogs.com/buerjj/p/7655090.html

 

Question 5: drag the third-party framework code into the Xcode 9 project and an error is reported during use. For example, download the latest masonry source code from gitHub, drag the masonry file into the project, check copy items if needed, select create groups, and check Add to targets. The following code uses masonry:

[Self. tableView mas_makeConstraints: ^ (MASConstraintMaker * make ){

Make. edges. mas_pointer to (self. view );

}];

The masonry error is as follows:[UITableView mas_makeConstraints:]: unrecognized selector sent to instance 0x7f9c6f0b7200.

Cause: If Xcode 9 is dragged to a third-party code, the code will not be compiled in the project. After being dragged to the masonry folder, click Project-build phases-compile sources and you will find that there are no masonry files.

Solution 1:Click project-build phases-compile sources point + to add masonry to compilation.

Solution 2: Do not drag in. Click the project and right-click Add Files

Note: this should be the Xcode 9.0 bug, which is said to have been fixed in version 9.1beta. See this link: http://blog.csdn.net/thoris/article/details/78139274? LocationNum = 7 & fps = 1

Ps: Recently, when planning the path, it is also because of this error that third-party code is dragged into the integration of AMAP. The same method can be used. Test.

 

 

2. iPhone x adaptation

Problem 1: When the tabBar is available on the iPhone x simulator, the tabBar at the bottom of the push page will jump up, and then return back to the tabBar again, again normal, and then push again will beat.

Solution: add the following code to intercept the push of All controllers:

 

Question 2: The navigation bar height is incorrect. Because the system navigation bar is not used in the project, it is all custom views. Therefore, the height of the navigation bar on iphone x is still 64.

Solution: add the macro definition in the navigation bar and use [UIApplication sharedApplication]. statusBarFrame. size. height + 44 to dynamically obtain the height of the navigation bar. You do not need to modify other settings. You only need to adjust the height. Fortunately, the internal layout of the navigation bar is well encapsulated before customization.

 

Problem 3: The tabBar at the bottom increases.

Solution: because the system tabBar is used, the height is automatically adapted, but some la s in the view cannot work if the height is 49 relative to the original tabBar, therefore, determine whether the screen height is iPhone X and use a macro to define the height of tabBar. The macro definition is as follows:

// Whether it is iphoneX

# Define kIsIphoneX ([UIScreen mainScreen]. bounds. size. height = 812? YES: NO)

// Tabbar height

# Define kTabBarH (kIsIphoneX? 83: 49)

 

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.