How to scroll whole screen with multiple collectionview that have different scroll directions - ios

I want to have two collection views that scrolls like this: the goal
I have achieved this but I then have the problem that when I scroll down the green collection view scrolls for alone and not the whole view: collection view with scroll
I then locked the scroll in the green collection view and put a scroll view around the whole screen. But when you scroll the collection view gets cut like this: collectionview locked
I have seen other apps like medium have two collection view that scrolls in two directions but I can not figure out have to achieve this.
Medium home
To make the scroll view able to scroll have I done this to calculate the height of the two collectio views and then setting the heigt to the scrollview:
var size : CGSize
let height = firstView.frame.height +
secondview.collectionViewLayout.collectionViewContentSize.height
size = CGSize(self.view.frame.width,height)
scrollview.contentSize = size
And my guess is that I might want to do the same for the green collection view but I have not got that to work.
Thanks!

Take a UITableView (for vertical scrolling). Put a collection view (with horizontal scrolling) in the header of the table view. By doing this, you would have horizontally scrollable view and the problem of cutting of view would be fixed. Moreover, you will not have to take another view for vertical scrolling. You will achieve that with the cells of table view.
Design like Medium (or many other apps) are easily achievable this way. A table view (vertical scrolling), a collection view (horizontal scrolling) as table view's header, and rest everything would be managed by table view. Give it a try.

Related

Horizontally scrollable cell within vertically scrollable collection view: best way to implement?

I already have a UICollectionView whose layout is of UICollectionViewFlowLayout type and scroll direction is vertical. Something similar to this (from this site)
Now I need to add some sections to this collection view whose cells can show a horizontally scrollable collection of custom cells that will be different from the ones I already have. Something similar to this (also from this site):
I also need the items there to have a width less than the screen's width and to be able to see part of the next and previous items.
Behaviour of the horizontal scrolling could be either continuous like, let's say, the "Stories" section in Facebook app:
or with paging like in the App Store app I showed before.
Question: which would be the best way to implement this?
A) Outer collection view (vertical scroll)
--> custom cell containing an inner collection view (horizontal scroll)
--> items are inner collection view's cells
In this case, how would pagination be implemented?
B) Outer collection view (vertical scroll)
--> custom cell containing a scroll view (horizontal scroll)
--> items are views added as scroll view's subviews
In this case, how would pagination be implemented?
C) A different approach would be the most appropriate?
EDIT: another consideration: items to be horizontally scrollable will be different for iPhone and iPad devices.

Scroll Tableview Cell with outer Scrollview instead of It's own scroll ?

I have an Imageview covering half of the screen height and a tableview below it. Both are wrapped inside a UIScrollView. I want to scroll the whole view. Means inner scroll of tableview won't work and when I scroll, outer scroll will scroll image view up and then showing cells of tableview. At the end, Imageview will hide behind scroll and tableview content will take entire space. Can anybody tell me how to achieve this. ?
Thanks
I don't think you need the outer scroll view(UIScrollView). Why don't you add only the inner table view and image view to where your outer scrollview is added. The image view can be added either above or below the table view. Let say your image view is below the table view then your image view will be covered by table view. In order to make it fully visible, set the talbview's content inset top to imageview's height and its background to clear color. then you can see both image and table view contents without one covering the other. The last thing you need to do is you have to handle the image view's y position when you scroll the table view so it looks like they are in the same scroll view. Use the scroll view delegate that is already available to you and play with scroll view's content offset and image view's y position.
I answered some similar question here with some sample code. Hand off parent container's pan gesture to nested UICollectionView
It does with collection view but the main idea is same.

Vertical View Pager either in Swift or in Objective C

Is it possible to implement Vertical ViewPager or not?
if Yes the please suggest me how to do it.
I am working on an app, which is similar to Quiz App.
I want to implement Quiz App result screen in which I am looking to implement Vertical View pager.
Thank you
Abhishek
So that's simply a scroll view, or a subclass of (I.e. A table or collection view). The scroll direction is controlled by the content size (or the layout for the collection). Any scroll view can have paging enabled.
If using a table or collection you simply need to set the row height or item size to the size of the view. For a plain scroll view you add the page views as sub views and set their size to equal the scroll view frame.

Vertical and horizontal scrolling collection views in a view

I have a couple horizontal scrolling collection views and one vertical scrolling collection view that are added to the same view. These collection views are overlapping like this.
If you're touching the horizontal scrolling collection view I would still like to be able to scroll the vertical scrolling collection view and vice versa. Is that possible to do?

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