Cordova+ionic+angular 项目从 UIWebView 更换为 WKWebView ,通过IOS审核


当前 cordova-ios 最新版本 5.1.1 新版本 cordova-ios 将删除 UIWebView 代码中的所有引用。WKWebView 将是 Cordova 的默认 Web 视图。   一、添加 cordova-ios的 平台环境 当前最新版本 5.1.1 cordova platform add ios@5.1.1;   二、添加 WKWebView 插件 http://cordova.axuer.com/plugins/  cordova中文网 Cordova 项目中添加 cordova-plugin-wkwebview-engine 插件 cordova plugin add cordova-plugin-wkwebview-engine   config.xml 中需要添加配置                                三、可能存在的问题   1、解决 WKWebView 无法访问 http/https 请求     WkWebview 启动的 index.html 不能访问 http/https 请求,需要结合 cordova-plugin-wkwebview-file-xhr 插件。     插件默认只拦截 https 请求     Cordova 项目中添加 cordova-plugin-wkwebview-file-xhr 插件     cordova plugin add cordova-plugin-wkwebview-file-xhr     config.xml 中添加配置          2、标签中外链图片不显示     建议换成https协议,或者缓存本地调用     3、任然无法通过IOS审核     需要把项目中运用的cordova更新到最新版本;      4、WKWebview 无法显示下载的图片     真机下只能显示 Tmp 目录下的图片文件,所以如果你有下载、显示本地图片的,需要更换文件目录为 Tmp目录。     注:Tmp 目录是 file:///var/mobile/Containers/Data/Applications//tmp/     可使用 cordova.file.tempDirectory 常量得到这个目录