【发布时间】:2011-03-26 20:32:09
【问题描述】:
如果本地文件不存在,谁能提供或告诉我如何异步下载 PDF。
我的代码如下:
NSURL *url = [NSURL URLWithString:@"http://www.url.com"];
NSString *tempDownloadPath = [[self documentsDirectory]
stringByAppendingString:@"test.pdf"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadDestinationPath:[self documentsDirectory]];
[request setTemporaryFileDownloadPath:tempDownloadPath];
[request setDelegate:self];
[request startAsynchronous];
一旦完成,我会尝试调用它
[aWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[self documentsDirectory] pathForResource:@"test" ofType:@"pdf"]isDirectory:NO]]];
但是它要么崩溃,要么没有在我的 web 视图中加载任何内容。 有什么建议吗?
使用自文档目录进行编辑
【问题讨论】:
标签: iphone webview asihttprequest