IOS适配及优化

1:iOS下载适配

默认采用WKWbview,需要在代理方法里加入以下代码,代码如下:

(void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { 
//对外链和跳转 appstore、微信等特殊处理  
//适配可能出现的需要跳转到 safari 的情况  
NSURL *url = [navigationAction.request URL];  
if ([url.absoluteString hasPrefix:@"itms-services"]) {  
if (@available(iOS 10.0, *)) { 
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {  
}];  
} else {  
[[UIApplication sharedApplication] openURL:url];  
// Fallback on earlier versions  
}  
} 
else if ([url.absoluteString hasPrefix:@"https://itunes.apple.com/"]){  
if (@available(iOS 10.0, *)) { 
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { 

}];  
} else {  
[[UIApplication sharedApplication] openURL:url];  
// Fallback on earlier versions  
}  
}  
else if ([url.absoluteString containsString:@"openSafari=1"]) { 
if (@available(iOS 10.0, *)) { 
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { 
 }];  } else {  
 [[UIApplication sharedApplication] openURL:url];  
 // Fallback on earlier versions  
 }  
 } 
 decisionHandler(WKNavigationActionPolicyAllow);  
 }