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

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

Perhaps just outdated, but Redent84's answer is plain wrong.
You can solve this by adding:
scrollView.canCancelContentTouches = YES;

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!

Related

iOS Touches Began

What I want: Touch a button and a view is added right where the touch is. Without having to lift the finger the touches began/moved automatically begins working on the UIView. So without lifting the finger, I have touched the button and can drag the new view around.
What I don't know how to do:
Stop the touch events on the button and immediately send the touch events to the new view that is directly under the finger.
One option could be to ditch the button and just use the uiview touches to detect when to add the subview you want to let the user drag...
Daniel
As #Daniel suggested ditch the button and just use a UIView, but I believe you may need to have a UIPanGestureRecognizer in place to get your dragging.
You could set a flag when a new UIView is created and then forward any gesture events to that view - only while the user still has their finger down from the initial touch.
After the user has lifted their finger the new view can just deal with gestures by itself by adding a UIPanGestureRecognizer to it.

custom slide to reveal toolbar

i want to do a custom toolbar, something like the slide to unlock of android phones. In idle state, the user can see a button of the bottom left of the page. the user would then tap it, drag towards the right. When the user reaches the right end, the toolbar will then 'lock'. Buttons would be located at the toolbar.
I'm think of using a customview and touchmoved functions, but what I don't know how is how to make the view move with the touch, and how to actually lock the bar.
Everytime you move your finger the touchmoved function is called. In the touchmoved function you have to redraw the whole view or just set a new frame for this view. It pretty simple as you already know how to detect touches and react on them.

Pressing on a button causes UIScrollView to scorll

I'm having an inconsistent problem where sometimes I press on a button inside the scrollview. The scrollview catches the event and scrolls instead of the button getting the touch event.
Any idea how to solve this bizarre behavior.
Thanks
Don't move your finger while it's pressed down on the button. If you move your finger at all, the scrollview will cancel the touches sent to the button and process them itself. It must do this so that you can scroll by touching anywhere on the scrollview, not just an empty space.

Scrollview and image dragging issue

I have a scrollview that has a number of custom imageviews in it. I use the custom imageviews as I need to be able to drag any one of them off the scrollview and to another location on the iPad screen, bit like a photo picker.
Problem is if I want to scroll the scroll view most of the time the custom imageview gets the touch and moves rather than the desired scroll?
I notice in the sample code from Apple using the autoscroll example that they have the same issue but they have left a large gap between the images....ugly!
Is there a way to let the app know when you want the touch to be a scroll and when to be a drag?
Thanks
You could make a drag require holding for 1 second, similar to the behavior of the home screen when in editing mode: if you want to scroll, you just flick; if you want to drag, hold down for a moment until the icon enlarges, then you can move it.

How can I detect a touch on an animated subview ? Or click an animated UIButton?

I have a view that is moving. The view is sometimes on and sometimes off screen - it is twice the width of the screen.
In this view, there are buttons that I need to be able to click.
I've tried doing this in many ways already - using pure buttons
using touches began on UIView
I'm doing the animation using a CGPath in core animation
Any help would be most appreciated
Thanks
Whether the view is moving or not should irrelevent to the touch detection. If you have a UIButton object and are handling the UIEventControlTouchUpInside (forgot the exact name) event , it should be called when it sees a touch. Is that not working for you?