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.51k stars 1.1k forks source link

The appearance of skeletons is visible when the View Controller is displayed #459

Closed squandev closed 2 years ago

squandev commented 2 years ago

Description

When a view controller appears, in which subviews are specified using constraints, the skeleton's appearance animation is visible

What type of issue is this?

Requirements


SkeletonView Environment:

SkeletonView version: 1.25.1 Xcode version: 12.2 Swift version: 5.3

Attachments:

https://user-images.githubusercontent.com/40371778/135757200-8c9ce9d6-af05-40b6-91a7-1c78b185300f.mov

Снимок экрана 2021-10-03 в 17 04 48
squandev commented 2 years ago

At the moment, the only solution I have found is to call the function in DispatchQueue.main.async

Narek1994 commented 2 years ago

It happens because in viewDidLoad views are not constrainted yet, and skeleton also animates constraint changes, Try view.layoutIfNeeded() before showing skeleton, I had a same problem in a UITableViewCell and

func collectionSkeletonView(_ skeletonView: UITableView, prepareCellForSkeleton cell: UITableViewCell, at indexPath: IndexPath) {
        cell.layoutIfNeeded()
    }

this fixed the issue.

Juanpe commented 2 years ago

Hi guys, this issue has been fixed in the latest version (1.29.1).

Feel free to reopen a new issue if you find another issue 🙂