IOS 5:UIScrollView 不将触摸传递给 nextResponder

发布于 2024-12-21 06:58:21 字数 626 浏览 2 评论 0原文

我有一个 UIScrollView 的子类,并覆盖它的所有 4 Touches 函数。在那些 Touches 函数中, [[self nextResponder] Touches...][super Touches...] 用于传递触摸事件。

我还有一个视图控制器,在其中我也覆盖了所有 4 Touches 功能。在控制器中,我将 self.view 设置为: self.view = UIScrollview 的子类;

在 iOS 5 之前,当滚动视图上有触摸移动时,视图控制器的触摸功能可以接收所有触摸开始/移动/结束/取消调用。但在 iOS 5 中,他们不能,只能收到一个 touchesBegan 和一个 touchesMove

从代码日志来看,UIScrollView子类中的触摸函数总是被调用。

另外,如果我设置 subclass.enableUserInteraction=NO ,视图控制器中的触摸函数将被很好地调用。但我需要滚动视图与用户交互,所以我不能将其设置为否。

iOS 5 有什么我错过的不同之处吗?先感谢您。

I have a subclass of UIScrollView, and override all 4 Touches functions for it. In those Touches functions,
[[self nextResponder] Touches...] and [super Touches...] are used to pass the touches events.

Also I have a view controller in which I override all 4 Touches functions too. In the Controller, I set the self.view as: self.view = subclass of UIScrollview;

Before iOS 5, when there are touches move on the scrollview, the view controller's touch functions can receive all touch begin/move/end/cancel calls. But in iOS 5, they can't, only one touchesBegan and one touchesMove are received.

From the log of the code, touch functions in the UIScrollView's subclass are always called.

Also, If I set the subclass.enableUserInteraction=NO, the touches function in view controller will be called well. But I need the scrollview to have interaction with user, so I can't set it to no.

Is there anything different I missed in iOS 5? Thank you in advance.

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

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

发布评论

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

评论(2

滥情哥ㄟ 2024-12-28 06:58:21

有一个非常简单的解决方法:)

而不是:

[self.nextResponder touchesMoved:touches withEvent:event];

使用:

[[self.nextResponder nextResponder] touchesMoved:touches withEvent:event];

也适用于 TouchBegan 和 TouchBegan 。触动结束。

就是这样!问题消失了!现在触摸事件被传递给下一个响应者:)

There is a very simple work around :)

Instead of:

[self.nextResponder touchesMoved:touches withEvent:event];

Use:

[[self.nextResponder nextResponder] touchesMoved:touches withEvent:event];

Works also for touchesBegan & touchesEnded.

That's it! Problem gone! Now the touches events are passed to the next responder :)

我是男神闪亮亮 2024-12-28 06:58:21

看起来像是 iOS 5 的错误。请参阅此帖子:

touchesMoved 在 iOS5 中未触发iPhone for UIScrollView

“正如之前提到的,我向 Apple 记录了一个缺陷,他们最终回复了我。我引用:‘经过进一步调查,已确定这是一个已知问题,目前已解决正在接受工程研究。”他们给出了原始错误 ID #10213937。他们感谢您提交该错误,但没有提供任何解决方法。”

不幸的是,仍然不确定如何解决 iOS 5 问题。

Looks like an iOS 5 bug. See this SO post:

touchesMoved not firing in iOS5 for the iPhone for UIScrollView

"As mentioned before I logged a defect with Apple, they finally got back to me. And I quote: 'After further investigation it has been determined that this is a known issue, which is currently being investigated by engineering.". They give the original bug ID #10213937. They give thanks for submitting the bug, but do not offer any workarounds.'"

Still not sure how to solve for iOS 5 unfortunately.

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