【发布时间】:2015-02-19 12:49:02
【问题描述】:
错误 Domain=NSURLErrorDomain Code=-1017 "cannot parse response" 当我将一个 html 页面加载到 webview 中时,我得到了这个错误。谁能给我一个解决方案
【问题讨论】:
-
你能用你的代码解释一下吗
-
您是否提供了正确的 HTML 文件路径?
错误 Domain=NSURLErrorDomain Code=-1017 "cannot parse response" 当我将一个 html 页面加载到 webview 中时,我得到了这个错误。谁能给我一个解决方案
【问题讨论】:
试试下面的代码
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[webView loadHTMLString:htmlString baseURL:nil];
用您的文件名更改“示例”。您可能没有得到路径,这可能是问题所在。
希望这会有所帮助:)
【讨论】: