简体   繁体   English

使用特定的外部应用程序从我的iOS应用程序打开pdf文件

[英]Opening a pdf file from my iOS App with a specific external application

I am developing an iPad application which is capable of downloading different types of files from web. 我正在开发一个能够从网上下载不同类型文件的iPad应用程序。 I want to give user's, option to open downloaded files (those my application cant handle) to other applications installed in the device. 我想给用户提供打开下载文件(我的应用程序无法处理的文件)选项到设备中安装的其他应用程序。

I know this can be done by using UIDocumentInteractionController , but i want to skip the show options in this method. 我知道这可以通过使用UIDocumentInteractionController完成,但我想跳过此方法中的show选项。

For example: After downloading a pdf file from web, on tapping a button "Open", it should automatically open to adobe reader application in the device. 例如:从Web下载pdf文件后,点击“打开”按钮,它将自动打开设备中的adobe reader应用程序。

CustomURL is a useful method to launch a specific application, but it may be difficult to get URL schemes of some applications. CustomURL是一种启动特定应用程序的有用方法,但可能很难获得某些应用程序的URL方案。

Please share your thoughts. 请分享你的想法。

Thanks in advance. 提前致谢。

You need to do a method and call either from web option or local (do you want this?)option. 你需要做一个方法并从web选项或本地调用(你想要吗?)选项。

From web directly: 直接来自网站:

UIWebView *theWebView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];

NSURL *targetURL = [NSURL URLWithString:@"http://yoursiteweb/directory/file.pdf"];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[theWebView loadRequest:request];

[self.view addSubview:theWebView];

From your bundle after you I downladed the file: 在您下载文件后,从您的包中:

UIWebView *theWebView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];

NSString *path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[theWebView loadRequest:request];

[self.view addSubview:theWebView];

For example: After downloading a pdf file from web, on tapping a button "Open", it should automatically open to adobe reader application in the device. 例如:从Web下载pdf文件后,点击“打开”按钮,它将自动打开设备中的adobe reader应用程序。

You want to open another app. 你想打开另一个应用程序。 If you don't know its URL schema, how could you open it? 如果你不知道它的URL架构,你怎么能打开它? Through URL schema is the only way we can use to launch another app in one app. 通过URL架构是我们在一个应用程序中启动另一个应用程序的唯一方法。 Apple does not provide a way to get the list of app that can open the file. Apple没有提供获取可以打开文件的应用程序列表的方法。 So you need to know the exact URL schema for every app you want to open. 因此,您需要知道要打开的每个应用的确切URL架构。 Indeed a little frustrating. 确实有点令人沮丧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM