Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skeleton not working if UICollectionView cell's Nib is registered in code #41

Closed
kjoneandrei opened this issue Feb 14, 2018 · 2 comments

Comments

@kjoneandrei
Copy link

kjoneandrei commented Feb 14, 2018

Skeleton loading does't work if cells get register in code:
collectionView.register(UINib.init(nibName: "\(Cell.self)", bundle: Bundle.main), forCellWithReuseIdentifier: "Cell")

What did you do

  • Created UIViewController in .xib file
  • Added UICollectionView in UIViewController as a subview
  • Added view and collectionView as skeletonable
  • Created UICollectionView cell in a separate .xib file
  • Linked cell to UICollectionView by collectionView.register(UINib.init(nibName: "\(Cell.self)", bundle: Bundle.main), forCellWithReuseIdentifier: "Cell")
  • added delegate and dataSource for UICollectionView as self (UIViewController)
  • start animating in viewDidLoad
  • implemented SkeletonCollectionViewDataSource
  • run app

I would expect it to identify the cell and add Skeleton loading to it but instead just the UICollectionView animates

Steps to reproduce the behavior

Create a UICollectionView in a UIViewController placed in a .xib file and not .storyboard.
Register UICollectionViewCell in code as presented above.

SkeletonView version:
1.1.1
Xcode version:
9.2
Swift version:
4

@kjoneandrei
Copy link
Author

kjoneandrei commented Feb 15, 2018

looked a bit around the framework and it seems that in this case the cells in extension SkeletonCollectionDataSource: UICollectionViewDataSource get placed after func recursiveShowSkeleton gets called
so calling view.showAnimatedSkeleton() on the ViewController's view causes only the whole UICollectionView to animate (since there are no existing cells at that time)

I have created a fix for this in this pull request: #42

@Juanpe
Copy link
Owner

Juanpe commented Aug 2, 2018

Solved in the latest version 1.3

@Juanpe Juanpe closed this as completed Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants