禁用UIWebView中的链接? [英] Disable links in UIWebView?
问题描述
我正在将一些内容从网络加载到 UIWebView
,但我希望在 UIWebView $中禁用所有链接C $ C>。这可能吗?我可以解析文本,但我正在寻找更容易的东西。
I am loading some content from the web into a UIWebView
, but I'd like all links to be disabled in the UIWebView
. Is this possible? I could parse the text, but I'm looking for something easier.
推荐答案
你可以给 UIWebView
a 委托并实施 -webView :shouldStartLoadWithRequest:navigationType:
委托方法到返回NO;
(初始加载除外)。
You can give the UIWebView
a delegate and implement the -webView:shouldStartLoadWithRequest:navigationType:
delegate method to return NO;
(except on the initial load).
这将阻止用户查看除该单页之外的任何内容。
That will prevent the user from viewing anything but that single page.
提供评论中要求的示例...从 allowLoad = YES
然后:
To provide an example requested in the comments... Start with allowLoad=YES
and then:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
return allowLoad;
}
- (void)webViewDidFinishLoad:(UIWebView*)webView {
allowLoad = NO;
}
这篇关于禁用UIWebView中的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!