gpt4 book ai didi

iphone - 检测 UIWebView 中的 ontouchend 或 onClick 事件

转载 作者:行者123 更新时间:2023-12-03 21:19:53 24 4
gpt4 key购买 nike

如何检测 UIWebView 内的 onclick 或 ontouchend 事件?或者这有可能吗?

谢谢。

最佳答案

子类化 UIWebView 并实现

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{   
//Do your code here

[super touchesBegan:touches withEvent:event];
}

编辑

您可以使用此 UIWebViewDelegate 方法拦截按下的 URL:

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType 
{
NSURL *url = request.URL;
NSString *link = url.absoluteString;
NSLog(@"Link pressed: %@", link);

return YES;
}

关于iphone - 检测 UIWebView 中的 ontouchend 或 onClick 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5795056/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com