I'm about to do my first UICollectionView and from a syntax point of view it looks almost exactly the same as what you would do for a UITableView.
I'm trying to figure out how I could build a photo grid that is based on the image below.
Can this be achieved with a single UICollectionview, or do I need to do a static view for the big images and then two collectionViews beside it (yuck!) or can this be done with sections?
This can be achieved using a single collection view. You can customize your collection view using UICollectionViewLayout. UICollectionViewLayout is very powerful, and you can achieve almost every kind of layout with this. Here's a very in-depth tutorial explaining the UICollectionViewLayout. Understand it and change it to according to your needs.
Link
Related
How can I make a carousel like this with UICollection view?
A UICollectionView has a collectionViewLayout which is of type UICollectionViewLayout. It is this layout object which is responsible for how the cells in a collection view are laid out.
If you want a layout object capable of stacking the cells on top of each other as in the image you've posted you can either build your own UICollectionViewLayout or use a layout which somebody has already created and made available. Examples are:
https://github.com/gleue/TGLStackedViewController
or
https://github.com/victor-pavlychko/DeckCollectionViewLayout
I am an Android dev trying to learn iOs development.
I am trying to implement a vertical scrolling UI inside an horizontal paging scroller (Like a RecyclerView inside a ViewPager).
I know I should use nested UICollectionView, I saw this tutorial doing similar stuff, however, it uses UITableView to create the reversed layout style (Horizontal scroll inside vertical scroll).
Can you tell me the best practice to implement this kind of layout? Is there any tutorial out there? I wasn't able to find really much (most stuff was regarding the reversed layout)
Thanks
edited:
1: if you want couple main pages you should implement uipageviewcontroller, to be able paging horizontally
2: if you want a lot reusable cells paging horizontally you should implement UICollectionViewController
if you need vertical scroll functionality inside every page/cells depends if you want paging/scrolling with many cells (you should use collection view) or scrolling some content like text or so (you want to use scrollview). And then you need to put UICollectionView/UIScrollView as a subview on your pages(uipageviewcontroller) / cells(collectionView)
btw. adding vertical scrolling if you need collectionviewcontroller would be bad idea, because you'd have many scrollviews within many cells
Is it possible to create a collection view with an item on the left and two items stacked to the right of it?
Whenever I specify the correct sizes to do this in the sizeForItemAtIndexPath delegate I can only get one item on the right side and the other is displayed in the next row underneath. I know I can do this with custom cells that contain more than one view (top and bottom) but I would like to know if its possible without that. It would be a lot less complex if I could do it without the custom double view cell. Im using a 'flow' layout with 'vertical' scroll direction (as per IB).
First image is what I hope to achieve and the second is what I am able to achieve currently.
You need to implement custom UICollectionViewFlowLayout subclass for this - Creating Custom Layouts
I want to implement a list containing several images grouped together like in the following mockup. The number of images to display in each section is dynamic and may vary. I also all images in a section to be always visible (without having to scroll horizontally or vertically).
What is the best approach to achieve this? I was making some tests with UICollectionView inside UITableViewCell but I can't make UICollectionView/UITableViewCell size expand automatically depending on the number of images inside.
Is UICollectionView/UITableViewCell the way to go or is there a simpler approach?
You don't need the UITableView to achieve this, here is the link for the implementation of Sticky Header for the UICollectionView.
https://gist.github.com/evadne/4544569
You need to implement collectionView delegate and dataSource methods inside uitableViewCell. Look it:https://contentpedlar.wordpress.com/2016/10/22/uicollectionview-in-uitableview/
This in Swift, but you easy understand it in Objective-c
I'm designing a layout for my app that is going to take advantage of UICollectionView. I have created some moderately complex collectionView-based apps before, but I may need to subclass the layout class for this one. The main point I'm trying to figure out is whether I can have different sections of the same collectionView scroll in different directions.
Based on what I have read and tried so far, the only way to have one section scroll horizontally and another vertically would be by using multiple nested instances of UICollectionView.
This is a basic idea of my layout. My guess is that even with subclassing, a single UICollectionView would not be able to handle it. Or would it?
I think you could do it with a custom UICollectionViewLayout but I'd use the default flow layout with one cell containing something like a SwipeView for the section 0 and other cells in your section 1.