Reputation: 1537
I want the scroll view just scrolls vertically and I also try to capture horizontal swipes on the scroll view.
I try to subclass UIScrollView and override some method about touch event, but all failed.
The problem seems to be that when a user swipes horizontally with some accidental vertical movement(even just a little), the UIScrollView scrolls and my touchesEnded delegate method never gets called.
Upvotes: 2
Views: 1992
Reputation: 385590
Instead of overriding touchesBegan:withEvent:
and other methods, use a UISwipeGestureRecognizer
. It's much simpler.
“Gesture Recognizers” in the Event Handling Guide for iOS
UISwipeGestureRecognizer Class Reference
Upvotes: 3