2013-02-11 55 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; 
}