Questions tagged uicollectionviewlayout

Explore the latest questions and answers asked by our top developers.

MessageKit Collection View doesn’t display any cells after adding support for a custom cell`

I’ve read through the guide for creating a custom cell in MessageKit here, and SO questions like this I’m trying to create a custom cell; here’s my code for a cell that inherits from a UICollectionViewCell: import UIKit import MessageKit open class ChatReferenceCell: UICollectionViewCell { @IBOutlet weak var authorLabel: UILabel! @IBOutlet weak var referenceText: UITextView! […]

UICollectionView for non-grid or semi-grid layout

I am trying to implement a multi-row sequence of items (like Video editing sequence in Final Cut Pro or Adobe Premiere pro shown below). While I one can always implement it using UIScrollView and placing custom views manually, it would be tedious particularly in reordering items and animating changes and also zooming across the timeline […]

align single UICollectionViewCell to the left of the collectionView

I’ve got a collectionView that is inside a tableView cell. The collectionView has multiple sections. If a section has only one cell, the cell appears centered. How can I align that single cell to the left? The collectionView has the following flowLayout: let flowLayout = UICollectionViewFlowLayout() flowLayout.scrollDirection = .vertical flowLayout.sectionInset = UIEdgeInsets(top: 0, left: 0, […]

UICollectionView top cells disappear while animating keyboard appearance

I have UICollectionView with cells inside. Everything works well except one thing. During keyboard appearance animation, top cells that are about to go offscreen just disappear in place without any animation https://www.youtube.com/watch?v=hMt6DiJD5KU I have tried to implement finalLayoutAttributesForDisappearingItem but it has no any effect. Also tried to expand rect in layoutAttributesForElementsInRect override func layoutAttributesForElements(in rect: […]

By claustrofob
Published
Categorised as ios, objective-c, swift, uicollectionview, uicollectionviewlayout

Behavior of UICollectionViewLayout.layoutAttributesForElementsInRect

I have implemented my own collection view layout subclassed from UICollectionViewLayout. In prepare i calculate and cache layout attributes. In layoutAttributesForElementsInRect i filter out the ones that are out of rect: override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { return itemAttributesCache.filter { $0.frame.intersects(rect) } } I expected that data source method func collectionView(_ collectionView: UICollectionView, […]

By claustrofob
Published
Categorised as ios, objective-c, swift, uicollectionview, uicollectionviewlayout

Self-sizing Left Aligned CollectionView Crash on layoutAttributesForElements

I want to make a left-aligned self-sizing collectionView just like this one: and here is my sample project: https://github.com/DiaobaoMiaoo/LeftAlignedSelfSizingCollectionView After running the project, rotate the device from portrait to landscape, then press the red button. Then the app will crash seemingly from layoutAttributesForElements with log: Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘*** -[__NSArrayM […]

By Ke MA
Published
Categorised as ios, swift, uicollectionview, uicollectionviewlayout

Collection view grid last row appears differently despite equal widths – swift iOS

I’ve a fixed grid of collection view cells (UICollectionView) but the cells in the bottom row always appears with a slightly smaller width on screen. The frame size (or bounds) and calculated width used within collectionViewLayout: UICollectionViewLayout sizeForItemAt are the same for all rows. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> […]

By DrWhat
Published
Categorised as ios, swift, uicollectionview, uicollectionviewlayout

UICollectionView animating cell beyond bounds

I set up a UICollectionView that has a following settings: collection view fits screen bounds only vertical scroll is applied most of cells fit to content’s width some of cells can change their heights on user interaction dynamically (animated) It’s pretty much like a UITableView, which works fine in most cases, except one specific situation […]

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq