gpt4 book ai didi

ios - 通过 UIDocumentInteractionController 打开文件

转载 作者:可可西里 更新时间:2023-11-01 05:34:53 27 4
gpt4 key购买 nike

我正在使用 UIDocumentInteractionController 在我的应用程序中打开文档。我使用以下方法预览 PDF 文件:-

- (IBAction)previewDocument:(id)sender 
{
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"];

// Initialize Document Interaction Controller
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];

// Configure Document Interaction Controller
[self.documentInteractionController setDelegate:self];

// Preview PDF
[self.documentInteractionController presentOptionsMenuFromRect:down.frame inView:self.view animated:YES];

}

我读到我们也可以通过 UIDocumentInteractionController 从一个应用程序中读取其他应用程序中的文件。

在我的应用程序中,如何使用 UIDocumentInteractionController 从其他应用程序读取文件?这一切是如何发生的?

最佳答案

预览 PDF 文档和共享。

设置委托(delegate)方法:-UIDocumentInteractionControllerDelegate

NSURL *URL = [[NSBundle mainBundle] URLForResource:@"Your PDF Name" withExtension:@"pdf"];
UIDocumentInteractionController *documentInteractionController =[UIDocumentInteractionController interactionControllerWithURL:URL];
documentInteractionController.delegate = self;
[documentInteractionController presentPreviewAnimated:YES];

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
return self;
}

如果您有任何困惑,请单击下面的链接并阅读: https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/PreviewingandOpeningItems.html

关于ios - 通过 UIDocumentInteractionController 打开文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25787248/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com