Html UIWebView如何检测<;img src="&引用/&燃气轮机;被敲打
我知道下面的方法可以检测链接元素点击。但是我想知道Html UIWebView如何检测<;img src="&引用/&燃气轮机;被敲打,html,ios,image,uiwebview,Html,Ios,Image,Uiwebview,我知道下面的方法可以检测链接元素点击。但是我想知道UIView是否可以检测到img元素是否被点击 - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ switch (navigationType) { case UIWebViewNavigationTyp
UIView
是否可以检测到img
元素是否被点击
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
switch (navigationType) {
case UIWebViewNavigationTypeLinkClicked:
NSLog(@"link is click");
//do something
break;
default:
break;
}
return true;
}
一些html源代码如下所示:
<p>xxxxxxxxx</p>
<p><img src="http://imgs.ebrun.com/resources/2015_06/2015_06_16/201506167911434413787546.jpg"> </p>
<p>xxxxxxxxx。</p>
<p><img src="http://imgs.ebrun.com/resources/2015_06/2015_06_16/201506167911434413787546.jpg"> </p>
<p>xxxxxxxxx。</p>
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
你能告诉我如何使用示例代码吗?谢谢。您的img标签没有html点击事件。如果你能让你的形象如下图所示-
<p>xxxxxxxxx</p>
<p><img src="http://imgs.ebrun.com/resources/2015_06/2015_06_16/201506167911434413787546.jpg" onclick="myfunction()"> </p>
<p>xxxxxxxxx。</p>
<p><img src="http://imgs.ebrun.com/resources/2015_06/2015_06_16/201506167911434413787546.jpg" onclick="myfunction()"> </p>
<p>xxxxxxxxx。</p>
您的img标记没有html单击事件。如果你能让你的形象如下图所示-
<p>xxxxxxxxx</p>
<p><img src="http://imgs.ebrun.com/resources/2015_06/2015_06_16/201506167911434413787546.jpg" onclick="myfunction()"> </p>
<p>xxxxxxxxx。</p>
<p><img src="http://imgs.ebrun.com/resources/2015_06/2015_06_16/201506167911434413787546.jpg" onclick="myfunction()"> </p>
<p>xxxxxxxxx。</p>
也许这个答案可以帮助你。基本上,您需要将标签包装在标签内,并在标签内处理按钮单击事件
webView:shouldStartLoadWithRequest:navigationType
方法也许答案可以帮助你。基本上,您需要将标签包装在标签内,并在标签内处理按钮单击事件
webView:shouldStartLoadWithRequest:navigationType
方法