JQuery Mobile 无法在 UIWebView 中工作 [英] JQuery Mobile not working inside UIWebView

查看:11
本文介绍了JQuery Mobile 无法在 UIWebView 中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过许多小时的寻找解决方案并尝试不同的方法来解决我在使用 JQuery Mobile 和 iPad 应用程序时遇到的这个问题后,我来到这里.

I'm coming here after many many hours of looking for a solution and trying different approaches to fix this issue I'm having with JQuery Mobile and my iPad app.

我想要做的是一个带有 Fusion Charts 的报告应用程序.我已经使用不同的方法并遵循不同的示例成功地在 Web 视图 (UIWebView) 中呈现图表,但我现在想做的是使用 JQuery Mobile 框架完成相同的任务.

What I'm trying to do is a reporting app with Fusion Charts. I have successfully rendered the charts within web views (UIWebView) using different methods, and following different examples, but what I'd like to do now is accomplishing the same task using the JQuery Mobile framework.

使用 phonegap,并且我已经按照有关 JQuery Mobile + Xcode 集成的步骤操作(我认为).图表在我的桌面和移动浏览器(iPad、iPhone 4 和 iPod Touch 2G)上加载没有问题,但它们无法加载到我的 UIWebView 中(即使我使用的是完全相同的代码).

I'm not using phonegap and I've followed the steps to the letter regarding JQuery Mobile + Xcode integration (I think). The charts load without a problem on my desktop and mobile browsers (iPad , iPhone 4, and iPod Touch 2G), but there's no way they load inside my UIWebView (even though I'm using the same exact code).

这就是我正在做的:

1) 将所需文件(JS、CSS 和 HTML)添加到项目以在本地使用它们.添加它们后,我将带有 .js 扩展名的所有内容从编译源"移动到复制捆绑资源".它看起来像这样:

1) Adding required files (JS, CSS, and HTML) to the project to use them locally. After adding them I move everything with .js extension from "Compile Sources" to "Copy Bundle Resources". It looks like this:

2) 将我的 HTML 测试文件 (page_A1.html) 加载到 Web 视图中:

2) Load my HTML test file (page_A1.html) into the web view:

3) 检查 HTML 文件中的所有内容是否都设置正确,并具有正确的路径和最新版本的框架:

3) Check that everything is set up on the HTML file with correct paths and latest version of frameworks:

4) 构建并运行只是为了得到一个空白的 web 视图.

4) Build and Run only to get a blank web view.

如果我用这样的警报测试 Javascript:

If I test Javascript with an alert like this:

它将显示证明 Javascript 正在工作的警报:

It will show the alert proving Javascript is working:

如果我在应该显示图表的容器上放一些文本:

And if I put some text on the container where the chart is supposed to be displayed:

我会在网络视图中获取文本:

I'll get the text inside the web view:

我还使用远程框架链接而不是本地链接和旧版本的库进行了测试,但没有运气.没有什么不同的发生:

I have also tested with remote framework links instead of the local ones and older version of the libraries with no luck. Nothing different happens:

在我看来很明显

$(document).ready(function(){

没有被 xcode 注意到或调用.

is not being noticed or invoked by xcode.

这就是我想要完成的:

我不知道还有什么要测试的.如果您有任何想法,我将不胜感激.

I don't know what else to test. If you have any idea I'd be more than grateful.

推荐答案

没关系.我终于明白了.

Nevermind guys. I finally got it.

网络开发时代的一些旧习惯让我在这里.

Some old habits from the web development days played me here.

事实证明,您不必为 CSS 和 JS 文件指定内部目录结构,因此:

It tuns out you don't have to specify the inner directory structure for your CSS and JS files so this:

<link rel="stylesheet" href="css/jquery.mobile-1.1.0.min.css" />

<script src="js/jquery-1.7.2.min.js"></script>

<script src="js/jquery.mobile-1.1.0.min.js"></script>

在 Xcode 中真的应该是这样的:

shoudl really be like this in Xcode:

<link rel="stylesheet" href="jquery.mobile-1.1.0.min.css" />

<script src="jquery-1.7.2.min.js"></script>

<script src="jquery.mobile-1.1.0.min.js"></script>

难以置信我花了多少时间才发现.

Unbelievable how much time it took me to find that out.

现在可以使用了.

这篇关于JQuery Mobile 无法在 UIWebView 中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆