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
10
votes
6 answers

Swift viewWillTransition not called

I'm creating a full screen image gallery using a UICollectionView. When the user rotates the device, I perform updates to the UICollectionView within func viewWillTransition(to size: CGSize, with coordinator:…
10
votes
1 answer

How to expand collectionview cell to full screen

I'm trying to print the image on fullscreen I used UICollectionViewDelegateFlowLayout here my code is func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) ->…
10
votes
2 answers

Drag and reorder - UICollectionview with sections

Is that possible to do drag and reorder from one section to another section from collectionview - iOS 9. Every time am dragging from 1st section to drop at 4th section am getting below crash, Assertion failure in -[UICollectionView…
vetrivel
  • 117
  • 1
  • 1
  • 8
10
votes
6 answers

How to detect if last cell is visible in UICollectionView?

I am trying to detect if the last cell in a collectionView is visible. var isLastCellVisible: Bool { let lastIndexPath = NSIndexPath(forItem: self.messages.count - 1, inSection: 0) let visibleIndexPaths =…
MJQZ1347
  • 2,607
  • 7
  • 27
  • 49
10
votes
4 answers

why is invalidateLayout is not triggering sizeForItemAtIndexPath in UICollectionView? (code attached)

The issue is the number of columns in the collectionView does NOT stay at 7 (the desired amount) upon rotation. What code change is required to fix this? It seems the invalidateLayout from the custom UICollectionViewFlowLayout is NOT triggering the…
Greg
  • 34,042
  • 79
  • 253
  • 454
10
votes
1 answer

Add border to custom CollectionView

How can I add border to UICollectionView's cells which uses a custom UICollectionViewFlowLayout? When I override UICollectionView's flow layout, cell borders are "removed". how can I set borders properly? Thank you!
10
votes
1 answer

UICollectionView Horizontal Scroll with Horizontal Alignment

I would like to have a paged UICollectionView, with each page displaying cells from left to right. What I can achieve now with classic UICollectionViewFlowLayout and layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; The result is…
PhilippeAuriach
  • 2,418
  • 2
  • 22
  • 41
10
votes
2 answers

UICollectionViewFlowLayout minimumInteritemSpacing doesn't work

I've got two problems with my UICollectionView: minimumInteritemSpacing doesn't work it overflows horizontally on iOS 6 I set up the layout like this: UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize…
10
votes
1 answer

Setting a UICollectionViewLayout subclass in a storyboard

I'm using a storyboard for my project and I want to have a scene that's a UICollectionViewController sub class, who's UICollectionView uses a UICollectionViewLayout subclass. I've set this up in a storyboard, and I'm trying to change the "Custom…
Benjohn
  • 13,228
  • 9
  • 65
  • 127
10
votes
2 answers

Display images in a UICollectionView - how to achieve fixed vertical spacing between images?

I am using a UICollectionView to present a grid of images in an iPhone app (iOS6). I am using vertical scrolling for the UICollectionView, and the images all have fixed width and varying height. The width of the images are set so that on an iPhone,…
Jonas
  • 625
  • 1
  • 6
  • 18
10
votes
2 answers

Multiple Decoration Views added to UICollectionView

I'm creating a basic collection view layout which subclasses UICollectionViewFlowLayout. However, I'm noticing that there appear to be several decoration views stacked on top of one another. Whenever the user selects an item in the last section, I'm…
Ash Furrow
  • 12,391
  • 3
  • 57
  • 92
9
votes
2 answers

How to animate collection view layout change while using `layoutAttributesForElements`?

I made a custom collection view flow layout that can toggle (with animation) between "film-strip" and "list" layouts. But after adding some fancy animations to the edge cells, the toggle animation broke. Here's what it looks like currently, without…
aheze
  • 24,434
  • 8
  • 68
  • 125
9
votes
2 answers

Section Header zIndex in UICollectionView CompositionalLayout - iOS 13

For some reason in new collectionview compositional layout zIndex property for section header is not working. I have tried below code to achieve the behaviour. func configureCategorySectionLayout() -> NSCollectionLayoutSection { let itemSize…
CrackIt
  • 606
  • 1
  • 5
  • 15
9
votes
4 answers

UIScrollView delegate methods not called when UICollectionViewCompositionalLayout is set

I currently have a UICollectionView using UICollectionViewCompositionalLayout. I would like to animate some views within the current visible cells while scrolling / scrolling stops. Unfortunately it seems setting orthogonalScrollingBehavior on a…
kye
  • 2,166
  • 3
  • 27
  • 41
9
votes
5 answers

Keyboard breaks layout in UICollectionViewController

I have a horizontal UICollectionViewController where each cell contains a UITextView at the bottom of the cell. When I tap inside the UITextView, while the keyboard is appearing, the CollectionView's height is reduced 260 points (which I notice is…
Stefano Giacone
  • 2,016
  • 3
  • 27
  • 50