IOS 5:UIScrollView 不将触摸传递给 nextResponder
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一个非常简单的解决方法:)
而不是:
使用:
也适用于 TouchBegan 和 TouchBegan 。触动结束。
就是这样!问题消失了!现在触摸事件被传递给下一个响应者:)
There is a very simple work around :)
Instead of:
Use:
Works also for touchesBegan & touchesEnded.
That's it! Problem gone! Now the touches events are passed to the next responder :)
看起来像是 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.