打开 iOS 应用程序

Open In For iOS App

我必须设计一个 iOS 应用程序,它将下载一个 pdf 文件,并且 UIActivityViewController 将有一个 "open in"(UIActivity 子类化)。使用 OpenUrl 我将数据发送到另一个应用程序,我可以在 第二个应用程序 中获取 pdf 数据。

但我也希望 Safari 具有相同的功能。我想在 safari "open in" 中查看 second app 并且一旦用户在 Safari 中获得一些 pdf,用户可以单击打开以在 second 应用程序中获取 pdf 数据.

- (void)performActivity {

    NSString *urlstring=@"ran/jan/jena/getit";
    NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"ranjantest:///%@",urlstring]];
    BOOL checkurl=[[UIApplication sharedApplication]canOpenURL:URL];
    if(checkurl){
        [[UIApplication sharedApplication] openURL:URL];
    }else{
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"" message:@"No suitable App installed" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }

}

有什么建议吗?

确定让您的应用程序出现在 PDF 的 Safari 的 open in/with 选项中,您需要做的是将您的应用程序设置为与 xcode 中的特定文档类型相关联。

在“信息”选项卡中,您可以添加文档类型并指定 PDF,这会将您的应用程序关联到 PDF 文档,因此当您转到 safari 并下载 PDF 文档时,它将允许您使用 open in/with选项和 select 您的应用程序。

阅读 Apple Documentation for Document Type here,但从外观上看,您可能仍需要实施 UIDocumentInteractionController,但 Apple 文档解释了所有内容。