Is there any method forwarding event from UIButton to UIScrollView? - iphone

I want to forward event from button which in the scrollview to scrollview when the button touched down and dragged inside.
by Using button's "addTarget: action: forControlEvent" function, I can receive button down and drag event and also can move scrollview as I dragged.
But the problem is the scroll view doesn't react like origin scrollview's scroll. This means there is no accelerate animation when I finish dragging.
I'm looking for the method forwarding event to scrollView so that the scrollview can react as it dragged on itself even though the event from the button on the scrollview.
Is there anyone who knows this?

Related

Why does touchesBegan stop working when UIImageView in placed inside a UIScrollView?

UIView -> UIImageView
I know I have things somewhat working ok since I can tap on my UIImageView and see an NSLog() statement in my touchesBegan method.
.
UIView -> UIScrollView -> UIImageView
I drag that same UIImageView into a UIScrollView and touchesBegan no longer gets called when I tap on my UIImageView. (I haven't changed anything else. All the same connections, methods, and code remains unchanged.)
Why does touchesBegan no longer work? And what can I do to get it working again?
Add uitapgesture to get event
Code is
UITapGestureRecognizer *ges11=[[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(Handeltap:)];
[imagename addGestureRecognizer:ges11];
Create one action name "Handeltap" U will get called there.
by default UIImageView don't handle user gestures.
set UIImageView instance's userInteractionEnabled to YES
Have a look at the documentation for UIScrollView.
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 timer 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.
I'd also recommend reading the Scroll View Programming Guide.

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
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!

How to check UIButton position in a ScrollView?

I have a UIButton in a ScrollView. This button is hided by the NavigationBar, so it is visible only when the user drag down the ScrollView. I want to check the position of the UIButton, and if the y position is <= 41 then i want to display an Alert
How can I make this?
Thanks!! Bye
The position of the yButton never changes (As in the frame of the yButton is the same in the scroll view). What does change is the contentOffset property of the UIScrollView. So you can implement the delegate method – scrollViewDidScroll: which can implement the logic to determine if the button is in your desired state.

iPhone UIButton Parent Frame Changing Touch Up Inside Event Issue

I have a UIButton within a UIView. The button is docked on the bottom of the view using the Autoresizing Masks. The button is working fine when the view initially loads and the IBAction is being called successfully.
Now when I resize the height of the parent view the button stays docked at the bottom of the view, however now only half of the button responds to the touch events. If I resize the parent view height a bit larger then the button completely doesn't respond anymore.
Any ideas why this would be occurring?
It sounds as if you've got another view, most likely a transparent one, that is resizing improperly and covering up part of the button.
It seems that I was moving the main view as the inner view height was changing. I guess if the UIButton is outside the bounds of the self.view then touches are not received.

Scroll view touch detection

I have a problem in the touchesMoved handler with a view that is added onto a UIScrollView. I add a number of labels to the scroll view. Each of these labels contain some text and, on swiping my finger on the labels, I have to play a specific file for that text.
If I just add the view onto the window directly, I get all of the touch events in touchesMoved without any problem. When I add my view onto the UIScrollView and then add this to the window, there is some lag in the touchesMoved handler. I am not getting continuous touch points in touchesMoved as with the normal view. As a result, while swiping the finger from the view, it happens that some labels are missed.
Is the problem due to scroll view? The same code runs perfectly in normal conditions (without a scroll view).
Does anyone have any solution to this?
UIScrollView sets a timer on touchDown to be able to know if it should handle scrolling or if it should pass the events on to subviews.
There is a property on UIScrollView for controlling this behaviour:
#property(nonatomic) BOOL delaysContentTouches