【发布时间】:2014-05-27 12:03:49
【问题描述】:
在我的应用程序中,我从网络服务获取我的 PDF 作为 URL。现在我想将它存储在我的 iPad 中并在 adobe Reader App 中打开。我使用以下代码保存它并在 webView 中打开它
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[
NSURL URLWithString:socialURLString]];
// Store the Data locally as PDF File
NSString *resourceDocPath = [[NSString alloc] initWithString:[
[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent]
stringByAppendingPathComponent:@"Documents"
]];
NSString *filePath = [resourceDocPath
stringByAppendingPathComponent:@"pdfOne.pdf"];
[pdfData writeToFile:filePath atomically:YES];
// Now create Request for the file that was saved in your documents folder
NSURL *url = [NSURL fileURLWithPath:filePath];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[web setUserInteractionEnabled:YES];
[web setDelegate:self];
[web loadRequest:requestObj];
现在假设它存储在我的 iPad 中,我打开 Adobe Reader 应用程序并没有显示 PDF。我做错了什么?
【问题讨论】:
-
您确定它已正确存储在文档文件夹中吗?
-
不。我不知道它是否被存储。
-
@rmaddy:我可以从我的应用程序外部访问 pdf 吗?我的意思是,我想用 Adobe Reader 应用程序查看保存的 PDF。这可能吗?