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

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.

Related

Scroll bar scrolls but UIScrollView doesn't scroll

I have components in a UIScrollView. My scroll view works when it was in iOS 10 and Xcode 8 but after the update, my scroll view does not scroll. However, the scroll bar does scroll and can keep scrolling until it gets smaller and smaller. It is just the elements in the scroll view itself that doesn't scroll.
I have tried doing content size bigger than the frame size but it does not fix it. Here is my current views hierarchy.
If anyone can help me debug this, it would be greatly appreciated.
I fixed this by adding a content view to the scroll view, and then the scroll view should be the subview of main view. The hierarchy should look like this.
I encountered pretty much the same problem (scroll indicator moves and gets smaller but content doesn't move). In my case it was resolved by changing the AutoLayout constraint for the top of my content view within the UIScrollView. I had pinned it to the Frame Layout Guide rather than the top of the superview.

UICollectionView cannot scroll while containing UIScrollView decelerates

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).

How do I prevent a scroll view from letting a user (temporarily) scroll a UIScrollView out of it's content area?

UIScroll view lets me declared a scrollable area when I have too much content for one page. Strangely, the scroll view in question behaves as desired in the X-axis, with no scrolling whatsoever allowed. Unfortunately, the Y axis -- where scrolling is necessary -- doesn't 'clip' the allowed scroll area to the content size. The user can scroll outside of the content size, and only after they let go does scroll view 'bounce' back to the allowed zone.
I want to prevent the user from scrolling further up than there is content to view (down doesn't bother me) because it looks 'wrong' to have the header at the top of the scroll view pull down, leaving the regular background behind it.
If you are making your UIScrollView in interface this is as simple as deselecting the
"Bounces, Bounces Horizontally, and Bounces Vertically"
check boxes in your scrollView's attributes. If you are designing the UIScrollView in code you can add this.
self.textView.alwaysBounceHorizontal = NO;
self.textView.alwaysBounceVertical = NO;
self.textView.bounces = NO;

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.

horizontal scrolling of a scrollView in a scrollView - small problem

i have a scrollView that fits the whole screen. In that View i show some UIImages that scroll horizontally. Like in the PageControl Project from Apple.
Then, when the user taps the screen, i fade in a scrollView at the bottom with some other images. Also horizontally scrolling. Like in the ScrollView Project from Apple.
My problem is, that when i come to the end of the scrollView which was faded in, the upper scrollView also starts to drag. How can i stop that during activation of the second scrollView?
Redraw the frame limits on your first scrollView when the second enters the screen. That way, your touches won't respond to both views. This means you need a container-view to keep both views seperated from each other.
Then you just rescale it back whenever your second scrollView disappears.
Edit: or disable scroll in your first scrollview while the second is open.

Resources