2013-02-11 44 views
0

显示我加载PDF文件与下面的代码UIWebView本地PDF:如何检测超链接在一个UIWebView

NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@", pdfString] ofType:@"pdf"]; 
NSURL *url = [NSURL fileURLWithPath:path]; 
NSURLRequest *req = [NSURLRequest requestWithURL:url]; 
[webview loadRequest:req]; 

它的正常工作。但我想在pdf文件中启用超链接(就像UITextView检测链接一样)。

+0

http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints和HTTP ://stackoverflow.com/questions/4080373/get-pdf-hyperlinks-on-ios-with-quartz LQ = 1 – iPatel 2013-02-11 09:26:07

回答

1

使用:

-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType 
{ 
    if (inType == UIWebViewNavigationTypeLinkClicked) { 
     [[UIApplication sharedApplication] openURL:[inRequest URL]]; 
     return NO; 
    } 
    return YES; 
}