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
许可也没问题。
答案 0 :(得分:0)
问题已解决:在使用之前,网址中还有另外的%25非转义:
[NSURL fileURLWithPath: .... ]
将其更改为:
[NSURL fileURLWithPath: [ .... stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]