【发布时间】:2012-01-07 08:05:13
【问题描述】:
我正在尝试以通常的方式在文件路径的 NSURL 中传递参数:
(fileURL)?arg1=val1&arg2=val2
问题是我不断从UIWebView 收到以下错误:
Failed to load webpage with error: The requested URL was not found on this server.
当我删除参数后缀时,一切正常。 Apple 上的文档说明该方法
+ (id)fileURLWithPath:(NSString *)path
像这样工作:"path: The path that the NSURL object will represent. path should be a valid system path..."
是否可以将参数添加到 fileURL?如果是这样,我该怎么做?
顺便说一句,如果我尝试使用 Javascript 调用从 UIWebView 加载带有参数的本地 URL 文件,我就成功了:
document.location = url;
我尝试从本机代码中找到解决方案...
【问题讨论】:
-
你能 NSLog 来自 fileURLWithPath 的输出吗?如果您在此处传递附加参数的路径,则 NSURL 可能会转义
?字符以使其成为 URL 的一部分。 -
path: xxxxxxx?arg1=something fileURLWithPath 输出: xxxxxxxxxx%3Farg1=something