在iOS上的PhoneGap或Cleaver(Cordova)中加载远程html [英] Loading remote html in PhoneGap or Cleaver (Cordova) on iOS
问题描述
我在我的本机iOS 6应用程序中使用了Cordova 2.4组件Cleaver和嵌入式视图。到目前为止,我已经设法创建项目结构,链接Cordova库和设置Hello World应用程序,提供设备就绪反馈。
I am using an Cordova 2.4 component Cleaver and an embedded view in my native iOS 6 application. So far I have managed to create the project structure, link the Cordova libraries and set up the Hello World app that does work providing "Device Ready" feedback.
这是所有伟大,但它加载来自www仓库分布在应用程序本身(包括所有js库)中的所有html。
This is all great but it loads all html from the www repository distributed inside the app itself (including all js libraries).
我真正想要的哟做的是:
What I really want yo do is this:
1 - 弹出cleaver组件比嵌入式uiwebview)在我的应用程序。容易做。
1 - popup the cleaver component (which is nothing else than an embedded uiwebview) in my app. Easy - done.
2 - 从指向远程服务器上的servlet的URL加载一些html内容。我有几个servlet,需要能够单独加载它们中的每一个。
2 - load some html content from a URL pointing to a servlet on my remote server. I have several servlets and need to be able to load each one of them separately of course.
3-有步骤2中生成的内容与我的本机应用程序通过cordova javascript libs cordova-2.4.0.js - (如何加载这些,如果他们是设备的本地,但html是从远程位置加载)。
3- have the content generated in step 2 interact with my native app via the cordova javascript libs cordova-2.4.0.js - (how do I load these if they are local to device but html was loaded from remote location).
我如何设置这个?
PS
我更多的是Obj-C而不是Javascript开发人员:)
I am more of Obj-C than Javascript developer :)
推荐答案
这是答案。什么喜悦...
Here is the answer. What a joy...
项目的第二部分是允许本地代码强制加载外部Web服务 - 我通过在Cleaver Web视图上调用stringByEvaluatingJavaScriptFromString实现了这一点。
Precisely what I needed. The second part of the project was to enable native code to force the loading of external web services - I accomplished this by called stringByEvaluatingJavaScriptFromString on the Cleaver web view .
[webview stringByEvaluatingJavaScriptFromString:@app.loadExternal('www.usatoday.com')];
是一个工作像一个魅力的代码:)
[webview stringByEvaluatingJavaScriptFromString:@"app.loadExternal('www.usatoday.com')];
is the code that works like a charm:)
Viola - 我有一个Cleaver视图,能够加载外部html内容,在javascript应用程序和本机容器之间具有完全的双向通信。
Viola - I have a Cleaver view capable of loading external html content with complete two-way communication between the javascript app and the native container.
这篇关于在iOS上的PhoneGap或Cleaver(Cordova)中加载远程html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!