2012-09-03 84 views
0

由于名称中有空白,WebView无法显示本地.htm文件。我收到提示WebView无法打开带有空格的本地html文件

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.} 

不过文件与取景器,并与终端上市已有:

ls -l 
total 6024 
[email protected] 1 olgadalton staff 3925 Oct 11 2011 Deployment Guide for Microsoft SharePoint Server 2010_split_000.htm 

权限也行。

回答

0

问题解决:

[NSURL fileURLWithPath: .... ] 

将其改为:

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

嗨奥尔加·多尔顿你能提供的示例代码中认为,需要在使用前要反向转义的网址有额外%25 –