Andrea Bellagamba
Andrea Bellagamba

Reputation: 21

ios uiscrollview delayscontenttouches only for vertical swipe

I am using a UIScrollView on the right side of my UIView. The ScrolView containes many UIImageView items and I allow only vertical scroling on the scrollview. The ImageView items can be dragged outside the scrollview to be placed on another view. The UIScrollview is set to delaysContentTouches = YES. This allows the nice feature of quickly scrolling the bar even when touching on one of it's content items, but on the other hand it introduces that little delay of about 0.15 seconds, when one of the content items is touched to be dragged into the other view.

Setting the delaysContentTouches = NO, allows the content item to be dragged with an horizontal swipe gesture but of course doesn't allow scrollview vertical scrolling on vertical swipe gesture.

So i would like to keep delaysContentTouches = YES, but somehow use it only on vertical swipe gesture, while for horizontal swipes i would like a behavior as if delaysContentTouches = NO

Any suggestion?

Thanks in advance

Upvotes: 2

Views: 1043

Answers (1)

Jerry101
Jerry101

Reputation: 13377

Try setting delaysContentTouches = YES and arranging the content view's width to equal the scroll view's width so no horizontal scrolling is possible.

The pan gesture recognizer might quickly recognize that no H scrolling is possible and thus end the delay early. Or maybe that only works when there's no H or V scrolling possible.

Upvotes: 1

Related Questions