我在 Resources 文件夹中有两个本地 .html 文件。我正在尝试通过以下方式加载它们,但只加载最后一页。我究竟做错了什么?
文件 = please_wait.html
这个不行。
NSError *error;
NSString* path = [[NSBundle mainBundle] pathForResource:@"please_wait" ofType:@"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
[webView loadHTMLString:htmlString baseURL:[NSURL fileURLWithPath:path]];
//Big "do-while" loop here. It works fine so I omitted it.
文件 = update_graph.html
这个不行
path = [[NSBundle mainBundle] pathForResource:@"update_graph" ofType:@"html"];
htmlString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
[webView loadHTMLString:htmlString baseURL:[NSURL fileURLWithPath:path]];
//Lots of code removed. All works correctly and doesn't touch webview
最后一个完美地工作。谷歌显示。
string = @"http://google.com";
NSURL *url = [NSURL URLWithString: string];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];