检测 UIWebView 内部的点击 - 而不是链接上的点击

发布于 2024-11-26 20:20:15 字数 104 浏览 0 评论 0原文

我想启用一些通过单击屏幕触发的功能。屏幕的视图是 UIWebView,我希望能够判断用户何时单击它,尽管不是当他单击其中的链接时,而是任何其他地方。

有什么想法吗?
嗯!

I want to enable some functionality that is triggered by clicking on the screen. the view of the screen is a UIWebView, and I'd like to be able to tell when the user clicks on it, though not when he clicks on a link inside of it, but any other place.

Any Ideas?
Tnx!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小梨窩很甜 2024-12-03 20:20:15

您是否看过 UIResponder 类参考

Have you looked at touchesBegan: / touchesEnded: in the UIResponder Class Reference

我不是你的备胎 2024-12-03 20:20:15

看看这个代码片段。它可能对你有帮助。

NSSet                   *touch;
CGPoint                 mTouchLocation;

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
touch = [event allTouches];
mTouchLocation = [[touches anyObject] locationInView:self.view];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
 NSLog(@"touchesMoving");
}


- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchEnded");
CGPoint newTouchLocation = [[touches anyObject] locationInView:self.view];  
}

当用户触摸屏幕时调用touchesBegan,当用户移动按住屏幕的手指时调用touchesMoved,当释放触摸时调用touchesEnded。

look at this code snippet. it might help you.

NSSet                   *touch;
CGPoint                 mTouchLocation;

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
touch = [event allTouches];
mTouchLocation = [[touches anyObject] locationInView:self.view];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
 NSLog(@"touchesMoving");
}


- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchEnded");
CGPoint newTouchLocation = [[touches anyObject] locationInView:self.view];  
}

touchesBegan is invoked when user touched the screen, touchesMoved when the user move the finger holding the screen and touchesEnded is when the touch is released.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文