简体   繁体   English

IOS 5:UIScrollView没有将触摸传递给nextResponder

[英]IOS 5: UIScrollView not pass touches to nextResponder

I have a subclass of UIScrollView , and override all 4 Touches functions for it. 我有一个UIScrollView的子类,并覆盖它的所有4个Touches函数。 In those Touches functions, [[self nextResponder] Touches...] and [super Touches...] are used to pass the touches events. 在那些Touches功能中, [[self nextResponder] Touches...][super Touches...]用于传递触摸事件。

Also I have a view controller in which I override all 4 Touches functions too. 我还有一个视图控制器,我也可以覆盖所有4个Touches功能。 In the Controller, I set the self.view as: self.view = subclass of UIScrollview; 在Controller中,我将self.view设置为: 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. 在iOS 5之前,当滚动视图上有触摸移动时,视图控制器的触摸功能可以接收所有触摸开始/移动/结束/取消呼叫。 But in iOS 5, they can't, only one touchesBegan and one touchesMove are received. 但是在iOS 5中,他们不能,只接受一次touchesBegan和一次touchesMove

From the log of the code, touch functions in the UIScrollView 's subclass are always called. 从代码日志中,始终调用UIScrollView子类中的触摸函数。

Also, If I set the subclass.enableUserInteraction=NO , the touches function in view controller will be called well. 此外,如果我设置subclass.enableUserInteraction=NO ,则将很好地调用视图控制器中的touches函数。 But I need the scrollview to have interaction with user, so I can't set it to no. 但我需要scrollview与用户进行交互,所以我无法将其设置为no。

Is there anything different I missed in iOS 5? 我在iOS 5中错过了什么不同的东西? Thank you in advance. 先感谢您。

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. 也适用于touchesBegan和touchesEnded。

That's it! 而已! Problem gone! 问题消失了! Now the touches events are passed to the next responder :) 现在触摸事件传递给下一个响应者:)

Looks like an iOS 5 bug. 看起来像iOS 5的bug。 See this SO post: 看到这个SO帖子:

touchesMoved not firing in iOS5 for the iPhone for UIScrollView touchesMoved没有在iOS5中为UIScrollView的iPhone触发

"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.". “正如我之前提到的那样,我记录了Apple的缺陷,他们终于回复了我。我引述:'经过进一步调查后,已确定这是一个已知问题,目前正在通过工程进行调查。” They give the original bug ID #10213937. 他们给出了原始的错误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. 不幸的是,仍然不确定如何解决iOS 5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM