Am getting the PDF file link from my web view. when i click that link, i want to open that PDF file in my iBook application.
i got the contents from server. I showed that content in UIWebview like this.
In this content have a PDF link "Emerging Trends in Real Estate". When i choose this link, i want to open this pdf file in iPhone PDF reader applications like iBook, Adobe Reader. When i click this link it goes to webView Delegate method
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL* url = [request URL];
NSLog(@"PDF URL : %@",url);
if (UIWebViewNavigationTypeLinkClicked == navigationType)
{
if ([url isEqual:@"about:blank"])
{
return YES;
}
else
{
// Initialize Document Interaction Controller
documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
// Configure Document Interaction Controller
documentInteractionController.delegate = self;
// Present Open In Menu
[documentInteractionController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES];
}
}
return YES;
}
when compiler comes to else part i got an error. i displayed that error :
PDF URL : http://www.uli.org/wp-content/uploads/ULI-Documents/Emerging-Trends-in-Real-Estate-Americas-2014.pdf
2014-01-17 16:44:49.233 ULINewYork[3163:a0b] *** Assertion failure in -[UIDocumentInteractionController setURL:], /SourceCache/UIKit_Sim/UIKit-2903.23/UIDocumentInteractionController.m:1010
2014-01-17 16:44:49.234 ULINewYork[3163:a0b] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener: delegate: <NSInternalInconsistencyException> UIDocumentInteractionController: invalid scheme http. Only the file scheme is supported.
please give me some idea to handle this process.