好吧我一直在搜索和測試過去的幾周,我是這個xcode的新手,但我知道足以讓應用程序啓動並運行。所以我遇到的問題是增加了這個開放功能。我可以使用本地pdf(pdfs手動和本地加載應用程序)工作,但我似乎無法讓它適用於我目前在應用程序中查看的PDF。比方說,我提出了一個PDF,其中一個我沒有加載的應用程序,我甚至不知道URL是什麼,一個隨機的,我似乎無法弄清楚如何獲得開放的行動按鈕工作。繼承人我的代碼。哦,順便說一句,我試圖打開的Adobe Reader,再次我可以成功地做到與本地PDF格式,我安裝了應用程序和一切。請幫忙!對於在UIWebview上查看的任何PDF都是Open-In
1)注:我知道這將加載PDF本地其中工程:
- (IBAction)shareButton:(id)sender;{
NSString * currentURL = _webview.request.URL.absoluteString;
NSString * filename = [currentURL stringByDeletingPathExtension];
NSLog(filename);
NSString * filePath = [[NSBundle mainBundle]pathForResource:@"OOP_ObjC" ofType:@"pdf"];
NSLog(filePath);
docController =[UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:currentURL]];
docController.delegate = self;
docController.UTI = @"com.adobe.pdf";
[docController presentOpenInMenuFromBarButtonItem:_shareButton animated:YES];
[super viewDidLoad]
}
2)注意:這是什麼我一直試圖用它來下載PDF並加載它本地。但我不斷收到-[NSURL initFileURLWithPath:];
零字符串參數」
- (IBAction)shareButton:(id)sender;{
NSString * currentURL = _webview.request.URL.absoluteString;
NSString * filename = [currentURL stringByDeletingPathExtension];
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:filename]];
//Store the Data locally as PDF File
NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"mypdf.pdf"];
[pdfData writeToFile:filePath atomically:YES];
//Now create Request for the file that was saved in your documents folder
NSURL *url = [NSURL fileURLWithPath:filePath];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView setUserInteractionEnabled:YES];
[webView setDelegate:self];
[webView loadRequest:requestObj];
NSLog(filePath);
NSString * path =
[[NSBundle mainBundle]pathForResource:filePath ofType:@"pdf"];
docController =[UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
docController.delegate = self;
docController.UTI = @"com.adobe.pdf";
[docController presentOpenInMenuFromBarButtonItem:_shareButton animated:YES];
[super viewDidLoad]
}
奏效,但是當我按下它不保存正確的PDF按鈕,我有一個索引PDF具有多個環節分離的PDF文件,選擇一個,然後按下按鈕後它使我回到索引pdf,然後顯示按鈕在adobe中打開的工作,我只想保存我在屏幕上按下按鈕時所用的PDF,有什麼想法?感謝您的幫助,非常感謝。 – 2013-03-08 15:45:27
我最終得到它的工作,請大拇指這樣每個人都可以看到如何讓這個工作 – 2013-03-19 13:32:06