【问题标题】:Ios web view page loading errorios网页查看页面加载错误
【发布时间】:2015-02-19 12:49:02
【问题描述】:

错误 Domain=NSURLErrorDomain Code=-1017 "cannot parse response" 当我将一个 html 页面加载到 webview 中时,我得到了这个错误。谁能给我一个解决方案

【问题讨论】:

  • 你能用你的代码解释一下吗
  • 您是否提供了正确的 HTML 文件路径?

标签: ios iphone ios7 uiwebview


【解决方案1】:

试试下面的代码

NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[webView loadHTMLString:htmlString baseURL:nil];

用您的文件名更改“示例”。您可能没有得到路径,这可能是问题所在。

希望这会有所帮助:)

【讨论】:

    猜你喜欢
    • 2017-04-02
    • 2017-01-03
    • 2016-01-17
    • 2014-10-30
    • 2012-09-01
    • 2015-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多