Juanpe / SkeletonView

☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting
MIT License
12.53k stars 1.1k forks source link

The skeleton view do not complete hide. #399

Closed starlight173 closed 3 years ago

starlight173 commented 3 years ago

Description

I upgraded the library from 1.7 to 1.16 and got some problems about show and hide the skeleton view. After taking a look from open issue and the sample code as well, but I still not find out how to fix the issue :/

What type of issue is this? (place an x in one of the [ ])

Requirements (place an x in each of the [ ])


Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

SkeletonView Environment:

SkeletonView version: 1.16 Xcode version:12.5 Swift version:5.3

Steps to reproduce:

Please replace this with the steps to reproduce the behavior.

  1. Declare a table with 2 custom labels. One of them is dynamic height (line number = 0)
  2. Show view skeleton
  3. Hide vide skeleton

Expected result:

Please replace this with what you expected to happen. All dummy skeleton should be hidden after hide skeleton

Actual result:

Please replace this with of what happened instead.
The dummy skeleton views are with the table view cell. I also attach the sample tableview_autodimension.zip.

Attachments:

Simulator Screen Shot - iPod touch (7th generation) - 2021-06-06 at 15 30 08

Logs, screenshots, sample project, funny gif, etc.

harrisonsj commented 3 years ago

Seems like this is caused by the estimatedRowHeight being significantly smaller than the actual row height turns out to be, hideSkeleton only removes the skeleton from the 'visibleCells' which leaves some reused cells with the skeleton still active if the number of visibleCells is significantly less with your data loaded than it is using the estimatedRowHeight.

Works properly if you use self.tableView.hideSkeleton(reloadDataAfter: false) or set an estimatedRowHeight closer to what the actual row height will be (if possible).

starlight173 commented 3 years ago

Many thank to @harrisonsj . It works for me.

Juanpe commented 3 years ago

Thanks @harrisonsj for the research, I really appreciate it :)

I'll try to find a solution asap. BTW, feel free to create a PR with a solution if you know how to solve this issue ;)