jQuery没有加载到iPhone上 [英] jQuery not loading on the iPhone

查看:110
本文介绍了jQuery没有加载到iPhone上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用UIWebView来显示内容,并使用jQuery来操作该内容,但我无法加载jQuery。这是我设置UIWebView,设置baseURL和加载内容(本地包中的HTML文件)的代码:

I'm trying to use a UIWebView to display content, and jQuery to manipulate that content, but I can't get jQuery to load. Here's the code that I have setting up the UIWebView, setting the baseURL, and loading the content (an HTML file that's in the local bundle):

UIWebView *view = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];

NSData *htmlData = [[NSData alloc] initWithContentsOfURL: [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]]];
NSString *htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
[view loadHTMLString:htmlString baseURL:baseURL];

内容加载得很好,我已通过添加图片确认baseURL是正确的捆绑并在HTML中引用它,它的工作原理。在我的Macbook上使用Safari中的相同HTML jQuery加载也很好,并按预期工作。

The content loads just fine, and I've confirmed that the baseURL is correct by adding an image to the bundle and referencing it in the HTML, and it works. Using the same HTML in Safari on my Macbook jQuery is loading just fine, too, and working as expected.

我已经尝试过使用压缩的jquery-1.3.2.min.js和开发jquery-1.3.2.js,并且没有任何骰子。

I've tried both using the compressed jquery-1.3.2.min.js and the development jquery-1.3.2.js, and no dice for either.

任何想法?

推荐答案

Gah! EBCAK!

Gah! EBCAK!

当我将jquery javascript源复制到项目中时,它被复制到目标的编译源中,这当然会引发错误。我从编译源代码中删除了它,但没有将其添加回复制捆绑资源。

Turns out when I copied the jquery javascript source into the project, it was copied into the target's "Compile Sources," which of course threw errors. I deleted it from "Compile Sources" but didn't add it back to "Copy Bundle Resources."

/我反复拍打额头。

这篇关于jQuery没有加载到iPhone上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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