无法从UIWebView中的Resource加载JavaScript

spa*_*zel 1 iphone uiwebview ipad ios

我正在使用此代码将本地HTML文件加载到iOS中的UIWebView中

NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];

NSURL *url = [NSURL fileURLWithPath:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

[myWebView loadRequest:requestObj];
Run Code Online (Sandbox Code Playgroud)

页面工作正常,HTML中链接的图像加载正常.但是,页面链接的JavaScript未加载.

HTML,图像和JavaScript都位于同一文件夹中.(我项目中的资源/ Html)

如何加载JavaScript?

spa*_*zel 7

问题是XCode向我显示了一个警告:

警告:没有规则处理架构i386类型sourcecode.javascript的'$(PROJECT_DIR)/html/orientation.js'文件

这个答案包含解决方案.基本上,我不得不告诉XCode不要尝试构建JavaScript文件,并手动将它们拖到"Copy Bundle Resources"目录中.