ios – 通过UIDocumentInteractionController打开文件

ios – 通过UIDocumentInteractionController打开文件,第1张

概述我正在使用UIDocumentInteractionController在我的应用程序中打开文档.我使用下面的方法预览PDF文件: – - (IBAction)previewDocument:(id)sender { NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"]; 我正在使用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文档和共享.

设置委托方法: –
UIdocumentInteractionControllerDelegate

NSURL *URL = [[NSBundle mainBundle] URLForResource:@"Your pdf @R_404_6889@" 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打开文件全部内容,希望文章能够帮你解决ios – 通过UIDocumentInteractionController打开文件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1060680.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存