我正在开发适用于iPhone的Sencha触控应用程序。现在应用已准备就绪,可以在手机浏览器中正常使但是,现在我想分发我的应用程序,所以我使用的是PhoneGap。
我的所有HTML和JavaScript页面都部署在 http://170.60.26.20:8099/Sencha/Html/index.html 。现在我想使用phonegap加载该URL。建议我如何做到这一步。
我已经安装了phonegap-1.2.0-0版本。
答案 0 :(得分:4)
在xcode中创建新的Phonegap应用程序,您只需要修改index.html
文件夹中已存在的www
文件。
您可以使用window.location
javascript方法在手机应用中加载您的网络应用。
在PhoneGap(Cordova).plist中,将您的服务器添加到ExternalHosts
列表,并将OpenAllWhitelistURLsInWebView
设为YES
。
请尝试使用以下代码在phonegap应用中运行您的html页面。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<!-- Change this if you want to allow scaling -->
<meta name="viewport" content="width=default-width; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>LoadUrl
<!-- If you application is targeting iOS BEFORE 4.0 you MUST put json2.js from http://www.JSON.org/json2.js into your www directory and include it here -->
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
function onBodyLoad()
{
document.addEventListener("deviceready",onDeviceReady,false);
}
/* When this function is called, PhoneGap has been initialized and is ready to roll */
function onDeviceReady()
{
// do your thing!
window.location="http://web.me.com/djpinter1/iPhone/jqtouch/demos/main_tabbar/#ui";
//window.location="http://170.60.26.20:8099/Sencha/Html/index.html";
}
</script>
</head>
<body onload="onBodyLoad()">
</body>
</html>
答案 1 :(得分:0)
在您的xcode中,启动一个新项目作为phonegap项目。然后将项目文件夹中的文件复制到phonegap项目中的 www 文件夹。请记住index.html文件应该在父文件夹中,否则你必须在相应的类中相应地更改url调用webview。
您可以点这个链接
希望它会有所帮助