有没有一种方法可以让单击 UIWebView 的 html 中的链接来加载另一个 UIView 并将 url 的值传递给该 View ,而不是在同一个 UIWebView 中加载该 html 页面。所以基本上,修改在 UIWebView 中单击链接的默认操作。这可能吗?
最佳答案
在你的UIWebViewDelegate这样做:
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
if ( navigationType == UIWebViewNavigationTypeLinkClicked ) {
// do something with [request URL]
return NO;
}
return YES;
}
关于iphone 应用程序 webview 链接操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3218040/