IOS 11 adaptation and Xcode 9 tips

Source: Internet
Author: User

There are a lot of articles on the Internet for iOS 11, but there are still some pits you don't know about, so here's a summary of your problems with iOS 11 in your project.

Uiscrollview and sub-frame overall down-shift problem

The previous project used Uiviewcontroller's Automaticallyadjustsscrollviewinsets property, which was deprecated in iOS 11 and replaced by Uiscrollview's Contentinsetadjustmentbehavior. Disabling the iOS11 cannot take effect, resulting in an entire page layout error.

Ios11api

The workaround can be for iOS 11 with the new API:

if (@available (IOS 11,*)) {if ([TableView respondstoselector: @selector (setcontentinsetadjustmentbehavior:)]) { Tableview.contentinsetadjustmentbehavior = Uiscrollviewcontentinsetadjustmentnever;}}

If you want to further the VC level to disable can refer to the following macro

#define ADJUSTSSCROLLVIEWINSETS (ScrollView) do {_pragma ("clang diagnostic Push") _pragma ("clang diagnostic ignored \"- Warc-performselector-leaks\ "") if ([ScrollView respondstoselector:nsselectorfromstring (@ " Setcontentinsetadjustmentbehavior: ")]) {nsmethodsignature *signature = [Uiscrollview Instancemethodsignatureforselector: @selector (setcontentinsetadjustmentbehavior:)]; Nsinvocation *invocation = [Nsinvocation invocationwithmethodsignature:signature]; Nsinteger argument = 2;invocation.target = Scrollview;invocation.selector = @selector ( Setcontentinsetadjustmentbehavior:); [Invocation setargument:&argument atindex:2]; [Invocation retainarguments]; [Invocation invoke];} _pragma ("clang diagnostic Pop")} while (0)

If the Automaticallyadjustsscrollviewinsets attribute is not used in the project, then it is not necessary to adapt and continue to be controlled by the system. Detailed calculations for safe areas and margins can be found in the security Zone adaptation summary.

UITableView's setcontentsize, no problem.

The height estimate is turned on by default in IOS 11, heightforheaderinsection cannot take effect when viewforheaderinsection is not implemented, and closing estimates resolves the bug.

Self.tableView.estimatedRowHeight = 0;self.tableview.estimatedsectionheaderheight = 0; self.tableView.estimatedSectionFooterHeight = 0;

[[UIScreen mainscreen] bounds].size wrong

When you run iphone x, you find that the previously defined screen size macro is incorrect. The reason for this is that this size gets the startup diagram size that was loaded when the app was launched, just in the launch diagram of the iphone x size in the start chart, with a resolution of 1125*2436.

Navigation bar Item Disorder

Some controllers in the project need to customize the baritem of the navigation bar, and when the left and right Baritem are packed with the entire bar, push then pops back to the controller, and the Baritem frame is deformed directly. As follows

Item

The root of all evil is the addition of a new layer in the Uinavigationbar uibuttonbarstackview, no custom uinavigation is a mistake, forced to write a new view cover on bar, manually control the hidden and display. This is only a temporary compromise, if there is a good way, remember to share to me ~ If the position is only offset, you can refer to the navigation bar button location problem.

Name of the new iphone

@ "iphone10,1": @ "IPhone 8",

@ "iphone10,4": @ "IPhone 8",

@ "iphone10,2": @ "IPhone 8 Plus",

@ "iphone10,5": @ "IPhone 8 Plus",

@ "iphone10,3": @ "IPhone X",

@ "iphone10,6": @ "IPhone X",

Xcode 9 Tips

1. If the import picture fails, manually add it again in the build phases--->copy Binary with libraies.

2. When the Xcode 9 is packaged, remember to add 1024*1024 icons in the icon.

3, the chicken's Wireless debugging function (iphone battery ...) The two options can be checked in window-->devices and simulators. The premise is that the device has run over and is under the same LAN.

4, in the asset, you can create a color. Right-click the new image set to populate the RGBA value or hexadecimal value. Using the new colorwithname directly, the parameters are filled in with the name you created. But remember to differentiate the system version.

5, Command key recovery. You can select jumps to defintion in preferences-to-Navigation-->commadn-click.

6, Xcode 9 also allow multiple open simulator, but the company's computer ... Hey, don't say much.

Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

IOS 11 adaptation and Xcode 9 tips

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.