SkeletonView does not work with resizable UITableViewCells

Created on 10 Feb 2018  ·  9Comments  ·  Source: Juanpe/SkeletonView

⚠️ Please fill out this template when filing an issue.

What did you do?

  • Import import SkeletonView
  • Conform to SkeletonTableViewDataSource (aka class MyTabViewController : UIViewController, SkeletonTableViewDataSource, UITableViewDelegate { ... })
  • Set myTableView.isSkeletonable = true in viewDidLoad()
  • Set myTableView.rowHeight = UITableViewAutomaticDimension and myTableView.estimatedRowHeight = 414 as I am using a custom UITableViewCell with a UIView in it, containing three UILabels (one multiline, two single line)
  • Return cell identifier in func collectionSkeletonView(_ skeletonView: UITableView, cellIdenfierForRowAt indexPath: IndexPath) -> ReusableCellIdentifier { ... }
  • Call myTableView.showAnimatedSkeleton() before loading data to be displayed, and myTableView.hideSkeleton() after data has been received and myTableView.reloadData() has been called

What did you expect to happen?

The UITableView will show the animated skeleton and then the skeleton will disappear once the data has been loaded

What happened instead?

The UITableView shows a grey background, and the skeleton does not show. After calling myTableView.hideSkeleton(), the every loaded cell's height changes to the value provided inestimatedRowHeight instead of being dynamic.

SkeletonView Environment

SkeletonView version: 1.1
Xcode version: 9.2 (9C40b)
Swift version: 4.0

✅ fixed 🐞 bug 🗑 given up

Most helpful comment

After some vulgar slurs and a few gray hairs, I've finally discovered after calling:

view.hideSkeleton()
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = /*Your row height here*/
tableView.reloadData()

In that order, it will redraw the cell to the correct height instead of using the estimatedRowHeight. Cheers.

All 9 comments

hi @theblixguy! I'm going to check ASAP
Thanks

I've checked and it's working fine in the example project. Are you using storyboards? I've updated the example project with a table with automatic dimension.

Are you using storyboards?

Yes. I think it's an issue with AutoLayout constraints that's affecting the library. The UITableViewCells render completely fine in the UITableView when I run my app, despite the constraints related warnings in Interface Builder. So the automatic row height adjustment works (I also tested on other iPhones). But the SkeletonView does not work.

As a workaround, I created another UITableView with a duplicate UITableViewCell. I removed the UIView that was behind the UILabels on my cell (I was using it to have rounded corner cells) and I added a different set of constraints to the cells. I linked the table's data source and delegate to my main table's UIViewController and I modified the delegate methods so it returns the appropriate cell, number of rows, etc for the corresponding table.... and it works! I just show/hide the placeholder table whenever I am loading some data. It's not the best thing to do, but it works. Although, on smaller sized iPhones like the 5S, the skeleton labels extend beyond the safe area for some reason.

I'll look more into the constraints I am using on my cells, perhaps I can find a fix for it. The strange thing is that the cells show up fine on a real device, but for some reason the SkeletonView cells don't show up.

I'll update when I dig deeper and find some more details about why this happens.

Any update on this bug? Having same issue with a collection view, to create its duplicate as a workaraound seems overkill. ;(

我也遇到了同样的问题,请解决一下吧,感谢

After some vulgar slurs and a few gray hairs, I've finally discovered after calling:

view.hideSkeleton()
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = /*Your row height here*/
tableView.reloadData()

In that order, it will redraw the cell to the correct height instead of using the estimatedRowHeight. Cheers.

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.

Yep, it's necessary to specify estimatedRowHeight when row height is dynamic. You can check here

My god!thanks,estimatedRowHeight must specify again!

Was this page helpful?
0 / 5 - 0 ratings