【问题标题】:WebView fails to open local html file with whitespaces in nameWebView 无法打开名称中包含空格的本地 html 文件
【发布时间】:2012-09-03 11:48:11
【问题描述】:

WebView 无法显示本地 .htm 文件,因为它的名称中有空格。我收到错误

Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this   server." UserInfo=0x400ea1900 {NSUnderlyingError=0x400265c80 "The requested URL was not found on this server.", NSErrorFailingURLStringKey=file:///Users/olgadalton/Library/Caches/ee.64.xxx/_books/Deployment-guide-for-Microsoft-SharePoint-Server-2010_2/OEBPS/Text/Deployment%2520Guide%2520for%2520Microsoft%2520SharePoint%2520Server%25202010_split_000.htm, NSErrorFailingURLKey=file:///Users/olgadalton/Library/Caches/ee.64.xxx/_books/Deployment-guide-for-Microsoft-SharePoint-Server-2010_2/OEBPS/Text/Deployment%2520Guide%2520for%2520Microsoft%2520SharePoint%2520Server%25202010_split_000.htm, NSLocalizedDescription=The requested URL was not found on this server.}

但是文件存在于 finder 和终端列表中:

ls -l
total 6024
-rw-rw-r--@ 1 olgadalton  staff   3925 Oct 11  2011 Deployment Guide for Microsoft SharePoint Server 2010_split_000.htm

权限也可以。

【问题讨论】:

    标签: macos cocoa webview


    【解决方案1】:

    问题已解决:url 中有额外的 %25 需要在使用前取消转义:

    [NSURL fileURLWithPath: .... ]
    

    改成:

    [NSURL fileURLWithPath: [ .... stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-08
      • 1970-01-01
      • 2019-08-06
      • 1970-01-01
      • 2013-12-05
      • 2012-09-30
      • 1970-01-01
      相关资源
      最近更新 更多