问题描述
我有一个混合应用程序,在iOS 7使用Cordova 3.7和jQuery Mobile 1.3.2完美工作
我在iOS 8上测试它,它是破碎的。
我使用 file://
协议请求每个页面(视图)我的应用程序的绝对路径,如:
file:/// var / mobile / Applications /< UUID> /MyApp.app/www/views/add-project.html
/ p>
但我得到错误:
无法加载资源:未在此服务器上找到。
我阅读了关于,是问题吗?
此外,在iOS 8上,www文件夹的位置有点不同于iOS 7,它解析为:
file:/// var / mobile / Containers / Data / Application /< UUID& MYApp.app/www/views/add-project.html
这是否正确?
我尝试了toURL()和toInternalURL()方法,使绝对路径像:
cdvfile:// localhost / root /var/mobile/Containers/Bundle/Application/<UUID>/MyApp.app/
但我总是有同样的错误。
任何建议?
感谢
可能会发现这有用,我终于设法解决问题。
ios上 www
文件夹的完整路径8+是:
file:/// private / var / mobile / Containers / Bundle / Application /< UUID> /< your_app> ; .app / www /
但是当您使用Cordova请求应用程序目录时,执行以下操作:
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory,onSuccess,onError);
给你一个错误的路径(iOS 8.1.2上的Cordova 3.7),如:
file://// var / mobile / Containers / Bundle / application /< UUID> /< your_app> .app /
使用docs上建议的toURL >
因此你需要手动做一些调整。
var path = fileSystem .toURL(); //由成功回调给出
IOS_ASSETS_ABS_PATH = path.replace(file:////,file:/// private /);
IOS_ASSETS_ABS_PATH + =www /;
和bingo!
I have an hybrid app that works perfectly on iOS 7 using Cordova 3.7 and jQuery Mobile 1.3.2
I am testing it on iOS 8 and it is broken.I am requesting each page(view) of my app using absolute paths, using the file://
protocol, like:
file:///var/mobile/Applications/<UUID>/MyApp.app/www/views/add-project.html
but i get the error:
Failed to load resource: The requested URL was not found on this server.
I read about this bug, is that the problem?
Also, on iOS 8, the location of the www folder is a bit different from iOS 7, it resolves to:
file:///var/mobile/Containers/Data/Application/<UUID>/MYApp.app/www/views/add-project.html
Is this correct?
I tried the toURL() and toInternalURL() methods to have the absolute paths like:
cdvfile://localhost/root/var/mobile/Containers/Bundle/Application/<UUID>/MyApp.app/
but I get always the same error.Any suggestion?
Thanks
To whoever might find this useful, I finally manage to solve the problem.
The full path to the www
folder on ios 8+ is:
file:///private/var/mobile/Containers/Bundle/Application/<UUID>/<your_app>.app/www/
but when you request the application directory with Cordova, doing:
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory, onSuccess, onError);
it will give you a wrong path (Cordova 3.7 on iOS 8.1.2) like:
file:////var/mobile/Containers/Bundle/Application/<UUID>/<your_app>.app/
using the toURL() method suggested on the docs
Therefore you need to manually do a bit of tweaking
var path = fileSystem.toURL();//given by the success callback
IOS_ASSETS_ABS_PATH = path.replace("file:////", "file:///private/");
IOS_ASSETS_ABS_PATH += "www/";
and bingo!
这篇关于使用Cordova 3.7(文件://)从iOS 8上的www文件夹加载资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!