UIView touch handling behavior changed with Xcode 4.2?

╄→гoц情女王★ 提交于 2019-12-04 05:33:49

I've been trying to track down the a similar issue for the last few hours. Finally managed to solve it with the help of this post

Actually it looks like I just managed to solve it, using the hint from https://devforums.apple.com/message/519690#519690
Earlier, I just forwarded the touchesEnded event to self.nextResponder. When I added touchesBegan, Moved, Cancelled handlers with similar implementations as the touchesEnded, the event seems to bubble up to the root view controller.
So I guess on iOS5, views discard touchesEnded events when they have not seen the relevant touchesBegan.

I didn't need to add Moved/etc., I just forwarded on TouchesBegan, and then TouchesEnded start working again!

Some touch handling did chance in iOS 5.0; especially if you re-link your application against the 5.0 SDK.

There's a section UIView's touch handling methods that says this:

If you override this method without calling super (a common use pattern), you must also override the other methods for handling touch events, if only as stub (empy) implementations.

So if you do one, you need to do them all. I know UIKit started taking steps to make sure this was the case in 5.0.

So I'd start there - override all the methods on your view and see what happens.

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