问题
I have to design an iOS app which will download a pdf file and there will be an "open in" by UIActivityViewController
(UIActivity
subclassing) .Using OpenUrl
I sent data to the other application and I can get pdf data in second application.
But I want the same functionality with Safari also. I want to see the second app in safari "open in" and once user get some pdf in Safari, user can click open in to get pdf data in second application.
- (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];
}
}
Any suggestion how to do it ?
回答1:
OK to get your application to appear in the open in/with
option of safari for PDFs what you need to do is set your application to be associate with that specific document type in xcode.
In the Info tab, you would add a Document Type and specify PDF this will associate your application to PDF documents so when you go to safari and download a PDF document it will allow you to use the open in/with
option and select your application.
Have a read of the Apple Documentation for Document Type here but by the looks of it you might still need to implement the UIDocumentInteractionController
but that Apple Document explains all.
来源:https://stackoverflow.com/questions/29140316/open-in-for-ios-app