【发布时间】:2015-04-09 01:48:04
【问题描述】:
我有一些关于 UIWebView 使用 cocos2d-js 动画加载本地 html 的问题。 事情是这样的: 文件夹的结构,如:
资源
| -> www
|->1
| -> 1.html,1.js
| -> res
| -> Cowboy.ExportJson,Cowboy.plist,Cowboy.png
。当我在 xcode 项目中拖动文件夹时,我选择“创建文件夹引用”,
我想加载“1.html”,它会调用1.js然后显示动画,但是牛仔资源无法加载成功,我 这是代码:
我捕获了异常,例如没有获取资源...
我尝试了 3 种方法来加载到我的 webView:
NSURL *url = [[NSBundle mainBundle] URLForResource:@"www/1/1" withExtension:@"html"];
NSString *html = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSLog(@"%@",[url URLByDeletingLastPathComponent]);
[self.webView loadHTMLString:html baseURL:[url URLByDeletingLastPathComponent]];
NSURL *requestUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"1" ofType:@"html" inDirectory:@"www/1"]];
[self.webView loadRequest:[NSURLRequest requestWithURL:requestUrl]];
NSURL *url = [[NSBundle mainBundle] URLForResource:@"www/1/1" withExtension:@"html"];
NSString *html = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSString *baseURL = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"www/1"]; self.webView loadHTMLString:html baseURL:[NSURL fileURLWithPath:baseURL]];
购买它们没有用。谁能帮我 。谢谢
【问题讨论】:
标签: ios objective-c uiwebview cocos2d-js