SkeletonView removes text from labels after hideSkeleton() called

Created on 28 Jun 2018  路  8Comments  路  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 have an array of views I show the SkeletonView on

let animation = SkeletonAnimationBuilder().makeSlidingAnimation(withDirection: .leftRight)
skeletonViews.forEach { $0.showAnimatedGradientSkeleton(animation: animation) }

Once my data is loaded I call

skeletonViews.forEach { $0.hideSkeleton() }

I have also run the same scenario with each show and hide call directly on the view/label.

What did you expect to happen?

My labels to be filled in with their original text.

What happened instead?

The text is removed and the labels are empty.

Steps to reproduce the behavior

Create labels in Interface Builder and set their text in IB. Show the gradient skeleton view and then hide it

SkeletonView Environment

SkeletonView version: 1.2.1
Xcode version: 9.4.1
Swift version: 4.1

Most helpful comment

@Juanpe please tag a new release, it is a pretty critical bugfix. Thanks.

All 8 comments

Same problem for me

Upon further digging into tickets and PRs it looks like this might be the intended action.

Would be nice to have the option to revert back to the old text.

I believe it is a bug in Recoverable.swift line 43:
text = text == "" || forced ? viewState?.text : text

The text is always nil at it is set to this in PrepareForSkeletonProtocol.swift line 17:

extension UILabel: PrepareForSkeleton {
    func prepareViewForSkeleton() {
        text = nil
        resignFirstResponder()
    }
}

Changing the check in Recoverable.swift to check for a nil OR empty string fixes the bug:
text = text == nil || text == "" || forced ? viewState?.text : text

I will fork and put in a PR now!

I've just noticed that the bug was actually fixed a couple of weeks ago:
https://github.com/Juanpe/SkeletonView/commit/ff42bd02e2b08f2c2e43df2397bf48a2ca5f57d9

but as there hasn't been a tagged release for over a month, the changes won't get pulled in with Carthage/Pods

@Juanpe please tag a new release, it is a pretty critical bugfix. Thanks.

This bug is fixed in version 1.8 :)

@Juanpe Hey, sorry for commenting on a closed issue, but I'm on SkeletonView 1.8.2 and a couple of my Labels are being hidden. Upon logging their texts, it does print the correct text but the labels aren't shown. Even tried label.isHidden = false but still can't get them to show.

still an issue in 1.8.6

Was this page helpful?
0 / 5 - 0 ratings