如何从 iCloud 打开 PDF
Posted
技术标签:
【中文标题】如何从 iCloud 打开 PDF【英文标题】:How to open a PDF from iCloud 【发布时间】:2018-08-03 16:49:52 【问题描述】:我有一个 iPad 应用程序,需要从 iCloud 获取 PDF 和视频,在 web 视图中打开 PDF,然后将索引路径保存在文档中,然后需要在另一个视图中打开它并保存在文档中。
到目前为止,我可以使用以下代码打开 iCloud 并下载:
(IBAction)openIcloud:(id)sender
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
【问题讨论】:
欢迎来到 Stack Overflow。您能否举例说明您想要实现的目标? 我可以从我的应用程序中打开 iCloud。我可以查看 iCloud PDF、视频、图像上的所有文档,并且可以下载它们。但我不知道如何在简单的 webview 中打开 pdf 下载 【参考方案1】:你非常接近它只是缺少这样的东西
#pragma mark - iCloud files
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url
if (controller.documentPickerMode == UIDocumentPickerModeImport)
docController =[UIDocumentInteractionController interactionControllerWithURL: url];
//NSURL *url = [NSURL fileURLWithPath:documentPickerMode];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[MywebWiev setUserInteractionEnabled:YES];
[MywebWiev setDelegate:self];
MywebWiev.scalesPageToFit = YES;
[MywebWiev loadRequest:requestObj];
- (IBAction)Pdf001:(id)sender
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
remember call <UIDocumentPickerDelegate,UIWebViewDelegate>
祝你愉快
【讨论】:
以上是关于如何从 iCloud 打开 PDF的主要内容,如果未能解决你的问题,请参考以下文章