Questions tagged [uicollectionviewdelegateflowlayout]

The UICollectionViewDelegateFlowLayout protocol defines methods that let you coordinate with a UICollectionViewFlowLayout object to implement a grid-based layout. The methods of this protocol define the size of items and the spacing between items in the grid.

33 questions
7
votes
2 answers

Screen goes black after segue

I have tried to debug this but to no avail. Basically when I segue from the first view controller to the second view controller the screen goes black momentarily. The code performs as I want it to but the screen going black is a bit of a pain for…
4
votes
1 answer

UICollectionView cell ignores UICollectionViewDelegateFlowLayout - sizeForItemAt

I am trying to layout the size of my collectionViewCell so that in each row there are 7 cells (easy right?). The cell is very simple, it only has a UILabel with top, left, bottom and right constraints of 0. I have setup the sizeForItemAt method as…
2
votes
2 answers

UICollectionView sizeForItemAt Called But Not Sized Correctly

I would like to have the first section's cells be the full width of the collection view and the second section be half of the width. On startup, the cells don't respect the given width although the height seems to be respected. After a couple of…
2
votes
3 answers

issue while set dynamic width of collection view cell

I am trying to dynamically set the width of collection view cell. Initially it's not rendering as expected. But when I tap on the cell, its getting adjusted as I want. Here's the code that I wrote: Code import UIKit class ViewController:…
2
votes
3 answers

CollectionView method 'referenceSizeForHeaderInSection' throws exception

I am trying to create headers for my collectionView with dynamic height. But when I implement "referenceSizeForHeaderInSection", the app crashes with the following exception: Terminating app due to uncaught exception…
1
vote
1 answer

Scaling down the height of a UICollectionViewCell dynamically

I am using UICollectionViewDelegateFlowLayout to display cells of dynamic height in my Collection View. The size of the cells are set in sizeForItemAt. Goal: Each Collection View cell has a toggle function that should change the…
1
vote
1 answer

UICollectionView layout behave weirdly on scrolling

I'm setting a collection View in order to display content as on instagram. instagram's grid In order to set the layout I'm using some delegate methods of UIcollectionviewDelegateFlowLayout : extension ProfileViewController :…
1
vote
3 answers

Collection View Cells are resizing unintentionally when scrolling to bottom of CollectionView

I am building a collection view (gallery) of images. The layout is 3 cells per row. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { …
1
vote
0 answers

Is there a way to return the size calculated by constraints in the sizeForItemAt UICollectionViewDelegateFlowLayout method

I'm overriding the sizeForItemAt method of UICollectionViewDelegateFlowLayout. What I'd like to do is only calculate the size if I'm in a certain section, and fall back to the default flow layout behaviour for the other sections. I'm not entirely…
1
vote
1 answer

How to make 2 rows in horizontal collection view without using sections

The horizontal scrolling in UICollectionView only returns one row and I need to make a horizontal scrolling collection view with 2 rows just like the image below [1]: https://i.stack.imgur.com/Vs1kt.png :[1]
1
vote
1 answer

Exception in collectionView(_:layout:sizeForItemAt:) when accessing layout.collectionViewContentSize

Achieve I want to have two different item sizes in a UICollectionView. Therefore I've implemented collectionView(_:layout:sizeForItemAt:) of UICollectionViewDelegateFlowLayout. Error But I'm facing the problem that my app crashes with an exception…
1
vote
0 answers

Right way to add collection view without behaviour of the UICollectionViewFlowLayout is not defined warning

My requirement is to have a slider collection view on top of my view in ViewController. I've tried many work around for my requirement (You can see that in my collection view setup code). But, time I receive the warning about The behavior of the…
0
votes
0 answers

UICollectionView minimumLineSpacing bug

I'm creating a horizontal scroll view through the collection view. I used flowlayout for layout, and I set the scroll direction to horizontal. I found a bug in this situation. If the width of the item is different, line spacing is not applied, but…
0
votes
0 answers

Layout problem in UICollectionView when reloading

I am using an UICollectionView to display a list of items in a 2 column layout with equal size of columns. This is obtained by a flow-layout. Simple. However, the first row is different from the rest, as it can vary from being full "screen" width or…
0
votes
0 answers

iOS - UICollection view with resizable cells on scroll with CompositionalLayout

I need a collection view with cells that are resizing on scroll as in the screen recording. I can do this with Flow layout, but have no idea how can I achieve this behaviour with Compositional layout?
1
2 3