我必須設計一個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