In my view I have a UITableView
which contains cells with horizontal UICollectionView
inside. The problem is that sometimes UICollectionViewCell
s are not rendered on device/simulator. At the same time I can see those cells in the View Hierarchy Debugger:
What I see in the View Hierarchy Debugger:
What I see on a device:
As you can see, cells (with images) exist and have correct frames and content (proved by the View Hierarchy Debugger). Nevertheless they are not rendered on device/simulator for some reason. What could be the cause of that and how could I fix it?
UPD: another example with "3D" view and bug on one cell, but not on the other
device screenshot:
view hierarchy debugger:
UICollectionView makes adding custom layouts and layout transitions, like those in Photos, simple to build. You're not limited to stacks and grids because collection views are customizable. You can use them to make circle layouts, cover-flow style layouts, Pulse news style layouts and almost anything you can dream up!
Add a CollectionView by pressing command shift L to open the storyboard widget window. Drag the collectionView onto the main view controller. Add constraints to the UICollectionView widget to ensure that the widget fills the screen on all devices. The foundation is now set up in the storyboard.
There are no section headers in the UICollectionView. So for your first task, you'll add a new section header using the search text as the section title. To display this section header, you'll use UICollectionReusableView .
A collection view manages an ordered set of content, such as the grid of photos in the Photos app, and presents it visually. Collection views are a collaboration between many different objects, including: Cells. A cell provides the visual representation for each piece of your content.
It turned out that my particular problem is related to UICollectionView assertion error on stale data because sometimes mentioned crash happens. Playing around [collectionViewLayout invalidateLayout]
I finally fixed this.
Just to record what was NOT the cause (and what you should check if faced with the same problem):
If none of the above is the cause of issue try invalidateLayout
somewhere around reloadData
or inside of layoutSubviews
or similar method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With