【发布时间】:2020-04-01 11:54:00
【问题描述】:
我正在从服务器下载多个 pdf 文件。下载完成后,我需要将 pdf 文件保存在本地并从 pdf 文件中获取并在 UIDocument 交互控制器中显示 pdf 文件。我是这样写的。但只显示一个文件。其余文件不显示。
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[self.data appendData:data];
NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES]; // get
/tmp folder path
NSURL *fileURL = [[tmpDirURL URLByAppendingPathComponent:@"temp_pdf"] URLByAppendingPathExtension:@"pdf"];
[self.data writeToURL:fileURL atomically:YES];
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
self.documentInteractionController.delegate = self;
[self.documentInteractionController presentPreviewAnimated:YES];
}
【问题讨论】:
标签: ios objective-c iphone xcode