Skeletonview: Skeleton UI doesn't work on a Subclass of UITableViewController or UICollectionViewController

Created on 4 Sep 2018  路  10Comments  路  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 tried to show skeleton UI in a table view of a subclass of UITableViewController class.

What did you expect to happen?

I expected 3 cells to show up with loading state of the image and label on each cell

What happened instead?

The table view shows it's own loading UI, animated light gray background, no cell shows up.

Steps to reproduce the behavior

class Cell: UITableViewCell {
    private let titleLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.preferredFont(forTextStyle: .headline)
        label.isSkeletonable = true
        return label
    }()

    private let myImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.isSkeletonable = true
        imageView.contentMode = .scaleAspectFit
        return imageView
    }()

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        isSkeletonable = true
        accessoryType = .disclosureIndicator

        contentView.isSkeletonable = true
        contentView.addSubview(titleLabel)
        contentView.addSubview(myImageView)

        NSLayoutConstraint.activate([
            ...
        ])
    }
}

class ViewController: UITableViewController {
    var items = [Item]()

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.isSkeletonable = true
        tableView.register(Cell.self, forCellReuseIdentifier: "Cell")
        tableView.showAnimatedSkeleton()
    }
}

extension ViewController: SkeletonTableViewDataSource {
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: ServiceTableCell.reuseIdentifier, for: indexPath) as! Cell
        return cell
    }

    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return items.count
    }

    func collectionSkeletonView(_ skeletonView: UITableView, cellIdentifierForRowAt indexPath: IndexPath) -> ReusableCellIdentifier {
        return "Cell"
    }

    func collectionSkeletonView(_ skeletonView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 3
    }
}

SkeletonView Environment

*SkeletonView version:1.4*
*Xcode version:9.4.1*
*Swift version:4.1*

Side note

I created a subclass of UIViewController, created a UITableView, added it to my view and make it fill it's bounds. That works as expected except the labels in each cell doesn't show up when the text content is empty.

I also have the same issue subclassing UICollectionViewController; the same solution of adding a collection view to a UIViewController subclass worked as well.

awaiting user input given up 馃 possible bug

All 10 comments

Same here

Same here :/

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.

same here

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.

How could this issue be closed - it's a serious bug - if not being solved in the near future, it should at least be mentioned in the documentation?

Hopefully it gets reopened. I have the same issue here!

Same here still.

Hi, could you check this comment, maybe it could fix our problem.

Let me know, thanks

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mohpor picture mohpor  路  6Comments

adelbios picture adelbios  路  6Comments

kak2008 picture kak2008  路  4Comments

Erumaru picture Erumaru  路  7Comments

eduardbosch picture eduardbosch  路  5Comments