Rich Brooks
Rich Brooks

Reputation: 521

UIScrollView with UIButton doesn't scroll when touch down on button

I've got a UIScrollView in my UIView. I've added some UIButtons to the scroll view.

If I touch down not on a button and drag, the scroll view drags fine. If I touch down on a button and drag then the scroll view doesn't move.

I want the scroll view to always scroll around if dragged and the buttons only get selected on the Touch Up Inside event.

I don't want to check "Delay Content Touches" because I don't want to have to wait for the delay.

Does anyone know what I need to do to get this to work?

Regards, Rich

Upvotes: 4

Views: 1762

Answers (2)

James Webster
James Webster

Reputation: 32066

Perhaps just outdated, but Redent84's answer is plain wrong.

You can solve this by adding:

scrollView.canCancelContentTouches = YES;

Upvotes: 3

redent84
redent84

Reputation: 19239

There's no automatic way of doing that. You have to manually handle the touch event, and then determine what the user wants to do, if he moves the finger X pixels up or down, then he wants to scroll, and if he releases the touch inside the button, then he probably wants to activate that action.

Regards!

Upvotes: -1

Related Questions