Finishing iOS9 adaptation

Source: Internet
Author: User
Tags password protection

This article is mainly about some iOS9 adaptation of the pit, if only to understand the iOS9 new features can be seen in the eyes of God's developers need to know the IOS 9 SDK new features. September 17 early morning, Apple to users pushed the IOS9 official version, with the user has been upgraded iOS9, also gradually derived a series of problems, the author also quickly for their own maintenance of the app to do the adaptation, this article wrote some of the pits are basically firsthand experience.

First, nsapptransportsecurity

IOS9 let all http default HTTPS, the original HTTP protocol transfer is changed to TLS1.2 protocol for transmission. The direct result is that when the app sends a request, the network fails to connect. The solution is to add the following node to the project's Info.plist file:

Nsapptransportsecurity-nsallowsarbitraryloads

This sub-node means: whether to allow wayward loading?! Set to Yes will disable the apptransportsecurity switch to the user-defined settings, the problem is resolved.

If you do not see this article in the Dong Yuan Blog Park, please click to view the original text.

It says that Apple restricts the HTTP protocol, but it doesn't mean that all https is perfectly suited to iOS9.

Take a chestnut, from within the app WebView loading HTTPS Web pages. Create a new project write a few lines from the page code

123456789101112 - (void)loadView{    UIWebView *web = [[UIWebView alloc]initWithFrame:[UIScreen mainScreen].bounds];    self.view = web;}- (void)viewDidLoad {    [superviewDidLoad];        UIWebView *web = (UIWebView *)self.view; //董铂然    NSURL*url = [NSURLURLWithString:@"https://github.com/"];    NSURLRequest*request = [NSURLRequest requestWithURL:url];    [web loadRequest:request];}

The middle URL is the HTTPS address that we want to load, with https://baidu.com/and https://github.com/to try each, the result is different

GitHub Web page can open, Baidu's Web page cannot open, the following print a line of log

1 NSURLSession/NSURLConnectionHTTP load failed (kCFStreamErrorDomainSSL, -9802)

The reason is that Apple's official profile says it must first be based on the TLS 1.2 version agreement. Then the cryptographic algorithm of the certificate also needs to reach the RSA key or ECC key of SHA256 or higher, and if it does not, the request is interrupted and nil is returned.

In the browser is can directly see this website encryption algorithm, first point green Lock point certificate information.

As you can see from the two images on the right, GitHub's SHA-256 with RSA encryption meets Apple's requirements, so it can be displayed.

The situation for Baidu can be configured in Info.plist as follows, if the site reference more than should be required for each site configuration.

Nsapptransportsecurity,nsexceptiondomains,nsincludessubdomains,Nsexceptionrequiresforwardsecrecy, Nsexceptionallowinsecurehttploads is written below for easy copying.

One of the Forwardsecrecy understood as the advanced password protection algorithm, in the official information has written, altogether is 11 kinds. After the configuration Baidu can access.

Second, Bitcode

Bitcode's understanding should be to compile the program into a transition code, and then Apple to compile the transition code into an executable program. Bitcode also allows Apple to re-optimize our program binaries in the late stages, with ideas like app slimming.

The following error may occur with the Xcode7 compiler to compile items that are not problematic before compiling.

1 XXXX’ does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode forthis target. forarchitecture arm64

The problem is due to the fact that some third-party libraries do not yet support Bitcode. Otherwise, wait for the library developers to upgrade this feature we update the library, or to disable this bitcode.

The disabled method is to find the following configuration, select No. (iOS Bitcode is the default Yes,watchos in Bitcodes is not allowed to change must be yes.) )

Third, set up trust

This article is only relevant to enterprise applications or inhose, not to the application of AppStore channels.

In iOS8 just pop up a window asking if you need to let the phone trust this app, but in iOS9 but directly banned, if you really want to trust yourself need to manually open. Similar to the MAC system downloaded from unknown developers, DMG directly will not open, and then to the system preferences of security and privacy manually opened. Show left IOS8, right iOS9

Users need to go to set---"General---" in the description file to add their own trust.

There are two ways to deal with this problem: 1. Do not upgrade IOS9 2. Most of the company employees use enterprise-class applications, mass a guidance mail.

Four, font

IOS8, the font is Helvetica,中文的字体有点类似于“华文细黑”。只是苹果手机自带渲染,所以看上去可能比普通的华文细黑要美观。 iOS9, the Chinese system font has become a specially designed for China "Ping Fang" is a bit like a word font "young circle". The font has a slight bold effect, and the most important thing is that the font gap gets bigger!

So many of the labels that were originally written to the width may appear "...".

IOS8

IOS9 Egg Pain

The above two graphs can also intuitively see the same interface, the same label changes.

So in order to display on the interface is not wrong, even if it is a fixed-length text is still recommended to use SizeToFit or iOS to take the whole CEILF () or Calculate in advance

12 CGSize size = [title sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:14.0f]}];CGSize adjustedSize = CGSizeMake(ceilf(size.width), ceilf(size.height));

Five, URL scheme

The scenario used by URL scheme is that the application has the ability to share or jump other platform licenses, share or authorize and then jump back.

There are not too many restrictions on iOS8, but iOS9 need to whitelist the URL scheme you want to call outside to complete the jump

If IOS9 does not make the appropriate match, it will report the following error

1 canOpenURL: failed forURL : "mqzone://qqapp"- error: "This app is not allowed to query for scheme mqzone"

The specific solution is to set the Lsapplicationqueriesschemes type to an array in Info.plist, and add all of the schemes you use below

Liu, TableView

Although the current iOS9 has been pushed to the official version, but iOS9 use will still feel the app more than ever, TableView drag when the most obvious lag display. And before encountering a bug, the original Good project with Xcode7 a compile, tableView refresh the problem, [TableView Reloaddata] Invalid there is a row of cells clearly changed but not to refresh. The feeling may be that this method conflicts with some of the new features, and it may be that the reloaddata operation is deferred until the next Runloop execution is final.

The solution is to comment [TableView Reloaddata], instead of local refresh, the problem actually solved.

1 [self.tableView reloadSections:[NSIndexSetindexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];

If you do not see this article in the Dong Yuan Blog Park, please click to view the original text.

Temporarily encounter these problems, feel iOS9 of the emergence of all iOS development is a tight, hope that Apple this drastic change, maverick style development after not and government contradictions, and then the company closed down led to the development of unemployment, perhaps I think more. I wish all iOS can be timely to do a good job to change the bug, the next version of the line, all problems are resolved.

Finishing iOS9 adaptation

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.