UICollectionView cannot scroll while containing UIScrollView decelerates - ios

I've implemented pretty common pattern: you could scroll horizontally between views (paging enabled) and you could scroll any "page" down for more details. It is done with parent UICollectionView containing UIScrollViews, see enclosed image:
Collection View can scroll only horizontally, Scroll View can scroll only vertically.
However I am unable to achieve "proper" horizontal scrolling. I cannot scroll horizontally while inner scroll view is decelerating which heavily decreases UX quality. Tried so far: directionalLockEnabled, delaysContentTouches, canCancelContentTouches, touchesShouldBegin: and gestures with requireGestureRecognizerToFail - all without success (but maybe not all done right).

Related

How to embed scrollview to tableview cell?

I have a scrollview embedded in a cell of tableview. The scrollview is a Foxit PDF rendering engine.
I want to scroll vertically the tableview, horizontally the scroll view. I couldn't. As on the first GIF you see scrollview is bouncing even the content height and scroll height is equal. But at least paging is possible.
Then I added a custom scrollview over the Foxit view into the cell. The bouncing disappeared and scrolling up and down the scrollview scrolls the table view. That is good. But now I can not horizontally scroll and change pages of the PDF.
What to do how to "merge" the two approach?
Try to play with panGestureRecognizer of scrollView and tableView. Install a relationship to prevent scrollView getting gestures before tableView scrollView.panGestureRecognizer.require(toFail: tableView.panGestureRecognizer).

How to prevent a non-scrollable UIScrollView from stealing scroll event?

To elaborate on my question, I've three scrollviews one top of another, let say base, middle and top. Base scroll view's content size is more so it will scroll, middle scrollview's content size is equal to its frame so it will not scroll, top scrollview's content size is more than its frame so it will also scroll.
Now when I scroll the top scrollview, once it reaches its end, I"m expecting it would scroll the base scroll view as middle is not scrollable. But it seems middle scroll view consumes all my scroll events and not letting the scroll event to go to base scroll view.
I"ve tried by setting more content size to middle scrollview, then it working as expected, first top scroll view scrolls fully then it passes the scroll event to middle scroll view then to the base scroll view.
Now it is more evident that middle scrollview (which is non scrollable) is consuming all of my scrolling event from going to base scroll view. How do I prevent that.
Note : As I've to support zooming, I need scroll view in all three levels.
Any help would be really appreciated.
Thanks.

Vertical UIScrollView over horizontal UIScrollView

iOS 8, Swift.
I'm trying to have a vertically scrolling view over a horizontally scrolling view. They're both UIScrollViews. The vertical scroll view is there to allow swiping up a view from the bottom. There is a spacer view on top using auto layout that is 1 pixel wide but the screens height.
This works fine until the underlying view is itself a scrollview to support horizontal scrolling.
I somehow need to pass the left/right pan gesture to the subview which is a UIScrollView.
Currently, the top level vertical scroll view is capturing all the gestures and not letting the underlying horizontal scroll view see the events.
I've tried various combinations of hitTest, gestureRecognizer delegate methods, scrollview subclassing but having come up with a nice clean solution.
I can use hitTest to pass events to the underlying horizontal scroll view when tapping the empty space at the top of the vertical scroll view, but then the vertical scroll view never processes a pan or swipe up to reveal the content that should appear on a swipe up.
Ideally, I'd like the top vertical scroll view to only handle pan up/down, and pass left/right pan to subview when the vertical scroll view is at the top.
Here's a brief method that may help you out:
Obj-C:
create scroll view that is invisible, and then pass the offset of the invisible scroll view or the touch events to the scroll views below depending on the offset of the touch events on the top invisible scroll view that covers the two underlying scroll views:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
[_verticalScrollView setContentOffset:CGPointMake(0, _insivibleScrollView.contentOffset.y)];
[_horizontalScrollView setContentOffset:CGPointMake(_insivibleScrollView.contentOffset.x, 0)];
}
You create an invisible scroll view, and by invisible, I mean you may have to keep the alpha value at like 0.01. You don't allow user interaction for the horizontal and vertical scroll views, but instead use the method above so that when the user touches the invisible scroll view you translate those touches to the scroll views below that are locked down to respond to only the offset of the invisible scroll view. As you've stated in your comment, there's probably more to this answer for your individual needs, but this is the basic "foundation" that will give you the effect that you probably want.
Swift:
Same method as above, but here's the function that you'll need:
func scrollViewDidScroll(scrollView: UIScrollView!) {
verticalScrollView.contentOffset = CGPointMake(0, invisibleScrollView.contentOffset.y)
horizontalScrollView.contentOffset = CGPointMake(invisibleScrollView.contentOffset.x, 0)
}

Two UIScrollViews, one scrolls vertically and the other horizontally

I found that Yahoo weather app has 2 scroll views, one can scroll vertically and the other can scroll horizontally.
These 2 scroll views are overlapped. How can I know which scroll view to scroll, based on the gesture?
For example, if I swipe up, the first scroll view should scroll up and the second one should remain unchanged.

UIScrollView an Paginator

I thought about the possibilities in UI Design for a new app. What I want to do is:
Have three view where the user can paginate horizontally. In each of this view there is a UIScrollView (fills the whole view) where the user can scroll vertically.
How could I manage, that horizontal scroll events are managed by the Pagination and vertical scrolls are managed by the ScrollView?
I'm sorry, maybe this is kind of a "beginner-Question"...
There might be a possibility to send the different touches to different UI-Elements?
Place the 3 scroll views inside a large scroll view.
The 3 vertical scrolling views should have a content size that matches the screen's width - this will stop them scrolling horizontally and the event will pass up to the the parent scroll view to allow horizontal scrolling.
Ensure that the content size of the parent view matches the screen height so that it only scrolls horizontally.

Resources