In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the problems that will be encountered in the adaptation of iOS 9. It is very detailed and has a certain reference value. Friends who are interested must read it!
1. NSAppTransportSecurity
IOS9 makes all HTTP use HTTPS by default, and the original HTTP protocol transmission is changed to TLS1.2 protocol transmission. The direct result is that the pop-up network cannot be connected when App sends a request. The solution is to add the following node to the info.plist file of the project:
NSAppTransportSecurity-NSAllowsArbitraryLoads
This child node means: is wayward loading allowed?! Setting it to YES will disable AppTransportSecurity and use user-defined settings instead, and this problem will be solved.
It is said above that Apple restricts the HTTP protocol, but it does not mean that all HTTPS can be adapted to iOS9.
Take Chestnut as an example, webView loads the https web page from within app. Create a new project and write a few lines of code from the web page
-(void) loadView {UIWebView * web = [[UIWebView alloc] initWithFrame: [UIScreen mainScreen] .bounds]; self.view = web;}-(void) viewDidLoad {[super viewDidLoad]; UIWebView * web = (UIWebView *) self.view; / / Dong Brunan NSURL * url = [NSURL URLWithString:@ "https://github.com/"]; NSURLRequest * request = [NSURLRequest requestWithURL:url]; [web loadRequest:request];}
The url in the middle is the https address we want to load. Try it with https://baidu.com/ and https://github.com/ respectively, and the results are different.
The page of github can be opened, but that of Baidu cannot be opened. A line of log is printed below.
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL,-9802)
The reason is that Apple's official sources say that it must first be based on the TLS 1.2 agreement. Then the certificate encryption algorithm also needs to reach SHA256 or higher RSA key or ECC key, if not, the request will be interrupted and return nil.
You can view the encryption algorithm of this site directly in the browser, click the green lock first and then click the certificate information.
As you can see from the two pictures on the right, github's SHA-256 with RSA encryption meets Apple's requirements, so it can be displayed.
For the situation of Baidu can be configured in info.plist as follows, if the site references more should be for each site configuration.
NSAppTransportSecurity,NSExceptionDomains,NSIncludesSubdomains,NSExceptionRequiresForwardSecrecy,NSExceptionAllowInsecureHTTPLoads is written below for easy replication.
Among them, ForwardSecrecy is understood as an advanced password protection algorithm, which is written in the official data, a total of 11. Baidu can access it after configuration.
II. Bitcode
The understanding of bitcode should be to compile the program into a transition code, and then Apple compiles the transition code into an executable program. Bitcode also allows Apple to re-optimize the binaries of our program at a later stage, with ideas similar to App slimming.
Projects that do not have a problem before they are compiled with the compiler of xcode7 may have the following error.
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 for this target. For architecture arm64
The reason for the problem is that some third-party libraries do not yet support bitcode. Either the developer of the waiting library upgrades this feature and we update the library, or we disable the bitcode.
The way to disable it is to find the following configuration and select NO. (bitcode in iOS is a must YES if bitcodes is not allowed to change in the default YES,watchOS.)
Third, set up trust
This article is only related to enterprise applications or inhose, and has nothing to do with the application of AppStore channels.
In iOS8, it just pops up a window asking if you need to get your phone to trust the app, but it's forbidden in iOS9. If you really want to trust, you need to open it manually. Similar to the dmg downloaded by the Mac system from unknown developers, it cannot be opened directly, and then it has to be manually opened to the security and privacy settings of the system preferences. The following figure shows iOS8 on the left and iOS9 on the right
Users need to set up-"generic -" description file to add their own trust.
There are only two ways to deal with this problem: 1. It is known in advance not to upgrade iOS9 2. Most of them are enterprise-level applications used by employees of the company, sending a group guidance email.
IV. Font
In iOS8, the font is Helvetica, and the Chinese font is somewhat similar to "fine black in Chinese". It's just that the iPhone comes with its own rendering, so it may look more beautiful than ordinary Chinese black. In iOS9, the Chinese system font has become "Apple", which is specially designed for China, which is somewhat similar to the "young circle" of a word font. The font has a slight bold effect, and the most important thing is that the font gap has become larger!
So many label that originally wrote dead width may appear "." The situation.
The above two pictures can also directly see the changes of the same interface and the same label.
Therefore, in order not to make mistakes in the interface display, even for fixed-length text, it is recommended to use sizetofit or ios to round up ceilf () or calculate in advance.
CGSize size = [title sizeWithAttributes:@ {NSFontAttributeName: [UIFont systemFontOfSize:14.0f]}]; CGSize adjustedSize = CGSizeMake (ceilf (size.width), ceilf (size.height))
5. URL scheme
The scenario commonly used by URL scheme is that the application has the ability to share or jump authorization from other platforms, and then jump back after sharing or authorization.
There are not too many restrictions in iOS8, but iOS9 needs to whitelist the URL scheme you want to call externally before you can complete the jump.
If iOS9 does not adapt, the following error will be reported
CanOpenURL: failed for URL: "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 the scheme you use below
VI. Statusbar
Fortunately, this is just a warning. If we leave him alone, there will be no problem.
: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
In the past, in order to control the style of the top statusbar in real time, we might like to use
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent] [[UIApplication sharedApplication] setStatusBarHidden:YES]
But before doing this, you need to set the View controller-based status bar appearance BOOL value in the info.plist to NO, which is to disable the permission of the controller to control the status bar and use UIApplication to control it. However, this practice is not recommended in iOS9. It is recommended that we set the BOOL value to YES, and then use the controller method to manage the status bar, for example.
-(UIStatusBarStyle) preferredStatusBarStyle {return UIStatusBarStyleLightContent;}
Click on the header file to verify what you just said:
@ property (readwrite, nonatomic,getter=isStatusBarHidden) BOOL statusBarHidden NS_DEPRECATED_IOS (2: 0,9: 0, "Use-[UIViewController prefersStatusBarHidden]")
7. DidFinishLaunchingWithOptions
If the following error is reported at run time, your didFinishLaunchingWithOptions is incorrect.
* Assertion failure in-[UIApplication _ runWithMainScene:transitionContext:completion:], / BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294**
IOS9 does not allow rootViewController for window that has not been set after the end of didFinishLaunchingWithOptions. Maybe xcode7's compiler itself doesn't support it.
The solution, of course, is to initialize a value first, and then assign it to replace it.
UIWindow * window = [[UIWindowalloc] initWithFrame: [UIScreenmainScreen] .bounds]; window.rootViewController = [[UIViewController alloc] init]
VIII. TableView
Although the current iOS9 has been pushed to the official version, but iOS9 will still feel that App is more stuttered than before, and stutter is most obvious when tableView is dragged. And before encountered a bug, the original good project compiled with xcode7, tableView refresh problems, [tableView reloadData] invalid there is a line of cell obviously changed but can not refresh out. It feels like this method conflicts with some new feature, and it is speculated that the operation of reloadData is postponed until the next RunLoop execution finally fails.
The solution is to comment [tableView reloadData] and use local refresh instead, and the problem is solved.
[self.tableView reloadSections: [NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone]; these are all the contents of the article "what are the problems encountered in iOS 9 adaptation?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.