UIScrollView
tries to figure out which touches to pass through to its contents, and which are scrolls, based on movement immediately after a touch begins. Basically, if the touch appears to be a scroll right away, it handles that gesture and the contents never see it; otherwise, the gesture gets passed through (with a very short delay for the first touch).
In my experience, I've been able to capture horizontal swipes in the contents of a UIScrollView
that handled vertical-only scrolling -- it basically just worked by default for me. I did this by setting the contentSize
to be the same as the width of the scroll view's frame
, which is enough information to tell the UIScrollView
that it won't be handling horizontal scrolling.
It sounds like you're having trouble with the default behavior, though. One hardware gotcha is that it's very hard to simulate a finger swipe on a laptop's trackpad. If I were you, I would test out the default UIScrollView
setup using either a mouse or, preferably, on the device itself. I found that these input methods work much better for conveying swipes.
If that doesn't work, here is a very pertinent paragraph from Apple's UIScrollView
docs:
Because a scroll view has no scroll bars, it must know whether a touch signals an intent to scroll versus an intent to track a subview in the content. To make this determination, it temporarily intercepts a touch-down event by starting a timer and, before the timer fires, seeing if the touching finger makes any movement. If the time fires without a significant change in position, the scroll view sends tracking events to the touched subview of the content view. If the user then drags their finger far enough before the timer elapses, the scroll view cancels any tracking in the subview and performs the scrolling itself. Subclasses can override the touchesShouldBegin:withEvent:inContentView:, pagingEnabled, and touchesShouldCancelInContentView: methods (which are called by the scroll view) to affect how the scroll view handles scrolling gestures.
In summary, you could try what they suggest by subclassing UIScrollView
and overriding the suggested methods.