获取 UIScrollView 上的 UIResponder 实例方法。 iPhone

发布于 2024-12-22 16:39:26 字数 412 浏览 3 评论 0原文

在我正在处理的当前项目中,在其中一个视图上,我有一个 UIView ,其顶部是由界面生成器构建的 UIScrollView

我已经实现了以下UIResponder实例方法:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

但是只有当触摸事件发生在UIScrollView未覆盖的区域时,控件才会调用此方法。

我怎样才能获得 UIScrollView 上的触摸事件?

on the current project I am working on, on one of the views, I have a UIView and on top of it UIScrollView which is constructed from the interface builder.

I have implemented the following UIResponder instance methods:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

but the control comes to this methods only when touch event occur in area where is not covered by the UIScrollView.

how I can get the hold of a touch event on the UIScrollView also?

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

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

发布评论

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

评论(1

凉栀 2024-12-29 16:39:26

您可以创建 UIScrollView 的子类并覆盖:

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view

您必须小心,不要干扰滚动手势等。

you could create a subclass of UIScrollView and override:

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view

you have to be careful that you don't interfere with the scrolling gestures etc tho.

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