IOS 5: UIScrollView not pass touches to nextResponder

心已入冬 提交于 2019-12-23 17:41:09

问题


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.


回答1:


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 :)




回答2:


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.



来源:https://stackoverflow.com/questions/8485853/ios-5-uiscrollview-not-pass-touches-to-nextresponder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!