Questions tagged [uicollectionviewlayout]

The UICollectionViewLayout class is an abstract base class that is used to generate layout information for a collection view.

The UICollectionViewLayout class is an abstract base class that you subclass and use to generate layout information for a collection view. The job of a layout object is to determine the placement of cells, supplementary views, and decoration views inside the collection view’s bounds and to report that information to the collection view when asked. The collection view then applies the provided layout information to the corresponding views so that they can be presented onscreen.

More: UICollectionViewLayout Class Reference

1496 questions
162
votes
11 answers

How to set cell spacing and UICollectionView - UICollectionViewFlowLayout size ratio?

I'm trying to add UICollectionView to ViewController, and I need to have 3 cells 'per row' without blank space between cells (it should look like a grid). Cell width should be one third of screen size, so I thought that the layout.item width should…
126
votes
25 answers

Paging UICollectionView by cells, not screen

I have UICollectionView with horizontal scrolling and there are always 2 cells side-by-side per the entire screen. I need the scrolling to stop at the begining of a cell. With paging enabled, the collection view scrolls the whole page, which is 2…
Martin Koles
  • 5,177
  • 8
  • 39
  • 59
126
votes
24 answers

Left Align Cells in UICollectionView

I am using a UICollectionView in my project, where there are multiple cells of differing widths on a line. According…
Damien
  • 1,647
  • 2
  • 16
  • 17
87
votes
24 answers

the behavior of the UICollectionViewFlowLayout is not defined, because the cell width is greater than collectionView width

2015-08-18 16:07:51.523 Example[16070:269647] the behavior of the UICollectionViewFlowLayout is not defined because: 2015-08-18 16:07:51.523 Example[16070:269647] the item width must be less than the width of the UICollectionView minus the section…
79
votes
14 answers

UICollectionView - Horizontal scroll, horizontal layout?

I have a UIScrollView that lays out a grid of icons. If you were to imagine the layout for the iOS Springboard, you'd be pretty close to correct. It has a horizontal, paged scroll (just like Springboard). However, it appears that the layout is…
Shadowman
  • 11,150
  • 19
  • 100
  • 198
75
votes
18 answers

iOS 10 bug: UICollectionView received layout attributes for a cell with an index path that does not exist

Running my app in a device with iOS 10 I get this error: UICollectionView received layout attributes for a cell with an index path that does not exist In iOS 8 and 9 works fine. I have been researching and I have found that is something related to…
cmacera
  • 1,140
  • 1
  • 10
  • 21
74
votes
16 answers

Aligning right to left on UICollectionView

this is a pretty straightforward question, but I haven't been able to find a definitive answer to it on SO (if I missed it, please correct me). Basically, my question is: Is it possible to align UICollectionView row contents from right to left…
63
votes
16 answers

UICollectionView Layout Issue

I am using UICollectionView using the flow layout. I have made a custom UICollectionViewCell for the same. But on running the project the console keeps on throwing this error- The behavior of the UICollectionViewFlowLayout is not defined because: …
Nitesh
  • 1,389
  • 1
  • 15
  • 24
63
votes
1 answer

Create a book shelf by using UICollectionView

I'm going to create a book shelf in one of my projects. The basic requirements are as follows: similar to iBooks bookshelf supports both orientations well supports all kinds of iOS devices well (different resolutions) supports deleting and…
Bagusflyer
  • 12,675
  • 21
  • 96
  • 179
59
votes
6 answers

How to create a centered UICollectionView like in Spotify's Player

I am have a lot of difficulty trying to create a UICollectionView like in Spotify's Player that acts like this: The problem for me is two fold. 1) How do I center the cells so that you can see the middle cell as well as the one of the left and…
55
votes
4 answers

Dynamic size UICollectionView cell

1) How can i achieve as shown in image with UICollectionView? 2) I've tried -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath method &…
54
votes
2 answers

UICollectionView doesn't bounce when datasource has only 1 item

I have a UICollectionView with a custom UICollectionViewFlowLayout. It scrolls horizontally and only shows one item at a time (full height). I have pagingEnabled = YES so that it sticks to pages. The UICollectionView shows photos within a…
52
votes
7 answers

What is a 'UIView-Encapsulated-Layout-Width' constraint?

I keep getting 'Unable to simultaneously satisfy constraints' exceptions (Xcode 5, iOS 7, both device and simulator), where one of the constraints in the list is something like this: "
44
votes
8 answers

UICollectionView horizontal paging - can I use Flow Layout?

This is related to but distinct from To use Flow Layout, or to Customize?. Here is an illustration of what I’m trying to do: I’m wondering if I can do this with a UICollectionViewFlowLayout, a subclass thereof, or if I need to create a completely…
Zev Eisenberg
  • 8,080
  • 5
  • 38
  • 82
43
votes
8 answers

UICollectionVIew: How can I remove the space on top first cell's row?

I have this arrangement in Interface Builder, all properties are set to zero. However, when I run it on both device and simulator it appears like this Where is the space above the cells come from? So I try to set these properties for…
SaintTail
  • 6,160
  • 4
  • 31
  • 51
1
2 3
99 100