Pass touches from a UIView to UIScrollView beneath it - ios

I have a UIScrollView stretching over the entire screen, which the user is able to scroll vertically only. Right 'above' it is a UIView with a few buttons, which covers the bottom 120 px only. The user may tap the buttons to invoke their selectors. But I wish to be able to pass the panning movement to the scrollView, so that the user may scroll the scrollView if they pan with a velocity greater than a certain threshold, if the panning begins over the UIView.
How would I go about it?
Thanks

You can do 2 things.
Add a UITouchesMoved function to your uiView, calculate finger movement and move your scrollView accordingly by scrolling it to a CGPoint.
You can use UIPanGestureRecognizer.

Related

IOS UIScrollView - scroll and click element at the same time

I have a UIScrollView with an button just outside the content area of the scrollView. The user has to scroll up and hold the spring effect which one finger and push the button with another finger. The problem is that the touch on the button is never detected.
Please see the illustration below
The scroll view in it's initial state. the orange area is the scrollView, the white area the button
The user is now scrolling and holding with one finger to overcome the spring effect of the UIScrollView, and want to click the button
Any suggestions?
Check this out:
UIScrollView blocks all touches while zooming or scrolling
Make sure you have multitouch set to YES on the scrollview and also don't have any subviews with exclusive touch enabled.

After scroll visible coordinates for the objects in the UIScrollView

I have a UIScrollView which contains 12 buttons. Only 5 buttons are visible at a time and rest all are not. When user clicks on a button i am animating a UIView from the position of the button. So when I scroll for hidden buttons and click view animation start from bottom from its original coordinates but not from the visible coordinates of the button.
When user scroll i want to know the visible coordinates of the button (contained in uiscrollview), so that I can animate from the button visible position. Or can anybody suggest which is the best way to implement this animation.
Note: My Scrollview is part of viewcontroller. I can't customize the scrollview as a parent class. Please help me asap to solve it as i am at the end of application development.
I just solved it using Scrollview convertPoint:toView API. Here is the solution:
CGPoint aPtInScrollView = [viewA convertPoint:aPoint toView:self.view];
Where aPoint is the object in scrollview 'position

UIScrollView within UIScrollView within UIScrollView

I have a multidirectional UIScrollView within a horizontal UIScrollView within a vertical UIScrollView. When I reach the horizontal content limit of the innermost scrollView, the containing horizontal scrollview begins scrolling just as I want.
But when I reach the vertical content limit of the innermost scrollView, I do not get any action on the top level vertical scrollView.
If all vertical content is visible at innermost level (so no vertical scrolling is possible), then the top level vertical scrollview takes over fine. Any clues on how to fix this?
I get this same behavior with Apple "PhotoScroller" sample code if I embed their photo paging scrollView in a vertical scrollView. If the photo is not zoomed, then both the horizontal and vertical scrollviews will work. If the photo is zoomed but panning stops because it has hit the horizontal or vertical limit, then only the horizontal scrollview works.
This is using an older version of the sample code that implements the photo paging as a UIScrollView rather than UIPageViewController. With current UIPageViewController version, paging is not possible when the photo is zoomed.
To answer my own question, I used gestureRecognizerShouldBegin: delegate to determine whether the innermost scrollView was at a boundary when the pan gesture began. If so, I responded to shouldRecognizeSimultaneouslyWithGestureRecognizer:
delegate to enable the UIPanGestureRecognizer on both the inner scrollView and the vertical scrollView. This allowed a single gesture to scroll both simultaneously. Then, I over-rode setContentOffset on both scrollViews to suppress the scrolling on the wrong one.
I think a better answer is probably to replace the UIPanGestureRecognizer on the inner UIScrollView with a custom gesture recognizer that cancels itself when started at a boundary and dragging past the boundary. But, I could not get that to work.
Still not clear to me why the horizontal version of this just worked automatically. Perhaps there is some special case handling in the UIScrollViewPanGestureRecognizer to handle horizontal case, or interaction with immediate superView.

How to touch UISlider thumb prevents UIScrollView scrolling

I have seen many similar questions to this but none help me exactly. I have many vertical UISliders filling a wide UIScrollView. If I drag the thumb on the slider I want the horizontal UIScrollView to be locked and only allow vertical sliding. If I drag the UISlider other than on the thumb I want the horizontal UIScrollView scrolling. It currently works if I touch the thumb before dragging.
I have overridden touchesShouldCancelInContentView in the scroll view but never hit the breakpoint in that method.
I had to override touchesShouldBegin:withEvent:inContentView and also set delaysContentTouches to NO to intercept the touch message.

Zooming and moving a UIScrollView at the same time

I have a UIScrollView that takes up a portion of the screen, and its basic functions (scrolling and zooming) work just fine. For example, I can grab the scrollview with two fingers, and scroll left and right, while zooming in or out on the content.
I want to add the ability to move the UIScrollView up and down at the same time. Please note that I do not want to move the content of the scroll view, but the scroll view itself.
I have attempted to add a UIPinchGestureRecognizer to the UIScrollView which has allowed me to grab and move the scroll view, but I then lose the zoom and scrolling. It seems that adding a gesture recognizer makes all of the default actions stop (also, when I call setZoomScale, I get an EXC_BAD_ACCESS).
I've also considered checking touches, but touches on the UIScrollView aren't registered with the main view so I can't change its location using those values.
Does anyone have any suggestions on how this might be accomplished?

Resources