【发布时间】:2015-02-13 10:13:29
【问题描述】:
I am using the Page View Application to show a series of PDF's. The UIWebView is displaying the PDF's fine, however whenever there is a link that is embedded into the PDF and the user clicks it, it opens the link inside of the UIWebView. I want it to open said link in safari.
NSString *path = [[NSBundle mainBundle] pathForResource:page ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[self.webView loadRequest:request];
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
return YES;
}
如您所见,我尝试插入代码来启动它,但单步执行时 BOOL 永远不会运行。
【问题讨论】:
-
你检查过其他导航类型吗?
-
是的,我试过了。问题是我无法单击 pdf 中的链接。当我使用 html 文件而不是 pdf 时,此代码工作正常。
标签: ios objective-c iphone uiwebview