Skeletonview: Collection View not showing skeleton for cells

Created on 25 Jun 2018  路  16Comments  路  Source: Juanpe/SkeletonView

鈿狅笍 Please fill out this template when filing an issue.

馃檹馃徏 Please check if it already exists other issue related with yours.

What did you do?

I am trying to show skeleton in collection view , i added an image view and a label to a cell set them both skeletonable and also set the cell to skeletonable and in viewDidLoad called showAnimatedGradientSkeleton() on collectionView.

What did you expect to happen?

I thought it should show the collectionView cells as skeleton.

What happened instead?

but it shows the whole collection view as skeleton and the cells dont appear, basically i just have a gray view with a gradient animation showing up.

Steps to reproduce the behavior

Add a collection view , add a cell to it , add imageview and label to cell set isSkeletonable to true
for all of them. Implement the protocol and then run

SkeletonView Environment

SkeletonView version: 1.2.1
Xcode version: 9.3.1
Swift version: 4.0
simulator screen shot - iphone 7 - 2018-06-25 at 18 17 53

given up

Most helpful comment

You can achieve with

collectionView.prepareSkeleton { [weak self] (done) in
                if let visibleCells = self?.collectionView.visibleCells {
                    for cell in visibleCells {
                           cell.contentView.showAnimatedSkeleton()
                    }
                }
            }

All 16 comments

Please help me with this, it works on the UItableView if i set the EstimatedRowHeight but since UICollectionView does not have any such property i couldn't resolve it. I also tried the sizeForItem method but it doesnt work also.

wow ! i just wasted a couple of hours for this and a dispatch of 0.1 sec resolved the issue.

@samsidd Hey I seem to have the same issue as you used to have. I wonder what does it mean by a dispatch of 0.1 sec?

I have the same problem

+1

The solution for me was to add in file SkeletonView.swift:
DispatchQueue.main.async after addDummyDataSourceIfNeeded() to fileprivate func recursiveShowSkeleton(withType type: SkeletonType, usingColors colors: [UIColor], animated: Bool, animation: SkeletonLayerAnimation?)
But I still have an issue with blinking content before skeleton appears

Hi, this issue should be solved in latest version (1.3).
You need to prepareSkeleton, you can check this PR (https://github.com/Juanpe/SkeletonView/pull/42)

still not fixed using 1.4

still not fixed

You can achieve with

collectionView.prepareSkeleton { [weak self] (done) in
                if let visibleCells = self?.collectionView.visibleCells {
                    for cell in visibleCells {
                           cell.contentView.showAnimatedSkeleton()
                    }
                }
            }

Still not fixed

@Juanpe please fix this ASAP. Temporarly I use saxahan's code to make it working. @saxahan thanks :)
SkeletonView v1.5

still doesn't work

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Doesn't work in tableviewcell too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamesTheKid picture jamesTheKid  路  4Comments

adelbios picture adelbios  路  4Comments

eduardbosch picture eduardbosch  路  5Comments

raphaklr picture raphaklr  路  5Comments

ghost picture ghost  路  7Comments