本文介绍了iOS 5:UIScrollView无法将触摸传递给nextResponder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIScrollView的子类,并为其覆盖了所有4种Touchs功能.在这些Touchs功能中,[[self nextResponder] Touches...][super Touches...]用于传递触摸事件.

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.

我还有一个视图控制器,在其中我也覆盖了所有4种Touchs功能.在控制器中,将self.view设置为:self.view = subclass of UIScrollview;

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;

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

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.

从代码的日志中,总是调用UIScrollView的子类中的touch函数.

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

此外,如果我设置了subclass.enableUserInteraction=NO,则视图控制器中的touches功能将被很好地调用.但是我需要滚动视图与用户互动,所以不能将其设置为否".

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.

我在iOS 5中错过了什么吗?预先谢谢你.

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

推荐答案

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

There is a very simple work around :)

代替:

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

使用:

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

也可用于触摸touchesEnded.

Works also for touchesBegan & touchesEnded.

就是这样!问题不见了!现在,触摸事件将传递给下一个响应者:)

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

这篇关于iOS 5:UIScrollView无法将触摸传递给nextResponder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-04 11:47