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

查看:116
本文介绍了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扩展名从Compile Sources移动到Copy Bundle Resources。它看起来像这样:

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)构建并运行以获取空白网页视图。

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将在Web视图中获取文本:

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>

shoudl在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天全站免登陆