Skeletonview: SkeletonTableViewDataSource numberOfRowsInSection never called

Created on 24 Feb 2020  路  7Comments  路  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?

Created UITableView with isSkeletonable set to true. All cells and its subview also isSkeletonable set to true. Implemented SkeletonTableViewDataSource and numberOfRowsInSection in MyViewController class. Set UITableView's dataSource to MyViewController. Called showSkeleton().

What did you expect to happen?

I expected UITableView to use

func collectionSkeletonView(_ skeletonView: UITableView, numberOfRowsInSection section: Int) -> Int

What happened instead?

It always uses

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int

Steps to reproduce the behavior

Steps mentioned in what did you do

SkeletonView Environment

SkeletonView version: 1.8.6
Xcode version: 11.3.1
Swift version: 5.0

馃 possible bug

Most helpful comment

Got the same issue. But instead of composing my own custom TableViewController (UIViewController + UITableView), I instead opted to subclassing UITableViewController. So somehow, you need to explicitly set this controller as the dataSource of the tableView to make SV work.

class CustomTableViewController: UITableViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    ...
    tableView.dataSource = self
  }
  ...
}

extension CustomTableViewController: SkeletonTableViewDataSource {
  ...
}

Without this, when you set a breakpoint at line 35 of the file UITableView+CollectionSkeleton, guard always fails because it detects that your dataSource is of type _UIFilteredDataSource and not SkeletonTableViewDataSource.

Here's my spec: _SkeletonView_: 1.8.7 | _Swift_: 5 | _Xcode_: 11.2.1

All 7 comments

showSkeleton should be called on your collection/tableView instead of your view :)

Me too.

@paulanatoleclaudot-betclic thanks for your response, but I call it on collection view.

Me too. It doesn't calculate how many cells need to populate the whole table view.

Boys, I resolved it. I used vc addsubview tableView.

First, you must set vc self.view.isSkeletonable = true
Second, for tableView must use estimatedRowHeight.

tableView.estimatedRowHeight = 130
tableView.rowHeight = UITableView.automaticDimension

Same problem here with 1.8.6 and 1.8.7. Fixed by reverting to version 1.8.5.
I am on Xcode 11.3.1 and Swift 5.1

Got the same issue. But instead of composing my own custom TableViewController (UIViewController + UITableView), I instead opted to subclassing UITableViewController. So somehow, you need to explicitly set this controller as the dataSource of the tableView to make SV work.

class CustomTableViewController: UITableViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    ...
    tableView.dataSource = self
  }
  ...
}

extension CustomTableViewController: SkeletonTableViewDataSource {
  ...
}

Without this, when you set a breakpoint at line 35 of the file UITableView+CollectionSkeleton, guard always fails because it detects that your dataSource is of type _UIFilteredDataSource and not SkeletonTableViewDataSource.

Here's my spec: _SkeletonView_: 1.8.7 | _Swift_: 5 | _Xcode_: 11.2.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

normand1 picture normand1  路  3Comments

ghost picture ghost  路  7Comments

pauloec picture pauloec  路  7Comments

jamesTheKid picture jamesTheKid  路  4Comments

kimsonwong picture kimsonwong  路  6Comments