我必须设计一个iOS应用程序,它将下载一个pdf文件,并将有一个“打开”UIActivityViewController
(UIActivity
子类)。使用OpenUrl
我发送数据到其他应用程序,我可以得到pdf数据第二申请。对于iOS应用程序打开
但我想要Safari也有同样的功能。我想在safari“open in”中看到第二个应用程序,并且一旦用户在Safari中获得一些pdf,用户可以点击打开以获取pdf数据第二个应用程序。
- (void)performActivity {
NSString *[email protected]"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];
}
}
任何建议如何做到这一点?
你有没有看过'UIDocumentInteractionController'(https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDocumentInteractionController_class/)这我相信可以让你下载你的PDF或选择一个已经存储在设备上,并为您提供可让您查看该PDF的应用程序。您可以使用'interactionControllerWithURL:'打开PDF文档,然后使用'Presenting and Dismissing Menus'中的一个向用户展示可用选项 – Popeye 2015-03-19 09:22:04
您的应用需要注册并处理自定义URL方案。看看苹果文件在这里:https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html – Kilogen9 2015-03-19 09:25:13
但我想看到我的第二个应用程序在Safari “打开”。使用openurl将数据从一个应用程序发送到其他应用程序可以正常工作。但是我想在safari中打开一些pdf,并且从safari“open in”需要打开我的第二个可以接收pdf数据的应用程序。希望我的问题清楚 – ranjanjena12345 2015-03-19 09:33:46