0

我必须设计一个iOS应用程序,它将下载一个pdf文件,并且会有一个“打开” UIActivityViewControllerUIActivity子类化)。使用OpenUrl我将数据发送到另一个应用程序,我可以在第二个应用程序中获取pdf数据。

但我也希望 Safari 具有相同的功能。我想在 Safari 中查看第二个应用程序“打开方式”,一旦用户在 Safari 中获得一些 pdf,用户可以单击打开方式在第二个应用程序中获取 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];
    }

}

有什么建议怎么做吗?

4

1 回答 1

0

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

在“信息”选项卡中,您将添加文档类型并指定 PDF,这会将您的应用程序与 PDF 文档相关联,因此当您进入 safari 并下载 PDF 文档时,它将允许您使用该open in/with选项并选择您的应用程序。

在此处阅读文档类型的 Apple 文档,但从外观上看,您可能仍需要实现UIDocumentInteractionController但 Apple Document 解释了所有内容。

于 2015-03-19T09:49:17.517 回答