UIWebView并单击链接 [英] UIWebView and click link

查看:85
本文介绍了UIWebView并单击链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道答案很可能是非常明显的,但我在互联网上无处不在,我找不到任何东西。我使用这种方法来查看用户是否按下了WebView

I know that most likely the answer is very obvious, but I've looked everywhere on the internet and I have not found anything. I use this method to see if the user presses on the WebView

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; {

我可以向你保证它有效。

I can assure you that it works.

我想要做的是根据ID做出不同的行动

What I want to do is to make different actions according to the id

es

<a id="hello" href="..."><img src="..." /></a>

一旦代表在img上用helloid检测到触摸点击,我会做一些自定义的东西,比如 [self callSomething];

once the delegate detect "touch click" on the img with the "hello" id, I would do some custom stuff, like [self callSomething];

你能告诉我如何使用示例代码?谢谢

Could you show me how to do it using a sample code? thanks

推荐答案

按如下方式更改您的代码

change your code as follows

  <a id="hello" href='didTap://image><img src="..." /></a>

并且在委托方法中尝试这样。

and in the delegate method try like this.

 - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
 {     
NSString *absoluteUrl = [[request URL] absoluteString];
 NSString*temp=[absoluteUrl stringByReplacingOccurrencesOfString:@"@" withString:@""];

if ([temp isEqualToString:@"didTap://image"])
{
    [self your method];
}
return YES;
    }

这篇关于UIWebView并单击链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆