cbpowell / MarqueeLabel

A drop-in replacement for UILabel, which automatically adds a scrolling marquee effect when the label's text does not fit inside the specified frame
MIT License
4.2k stars 563 forks source link

iOS 10 compatible problem #206

Closed Jenus closed 6 years ago

Jenus commented 6 years ago

Usage Details

Expected Behavior

when swipe back to the original ViewController, marqueeLabel can scroll again

Actual Behavior

when swipe back to the original ViewController, marqueeLabel can scroll stoped

Steps to Reproduce the Problem

  1. ViewController A with marqueeLabel(.speed(60)), scroll normally
  2. ViewController A push ViewController B
  3. swipe back so fast from ViewController B, ViewController A with marqueeLabel no scroll

The upper problem doesn't exist when iOS 11 or when swiping softly below iOS 11( iOS 10); When debugging, the line sublabel.layer.add(scroller.anim, forKey: "position") CATransaction.commit() //set breakpoint when commit() function execute stepped, scroll animation works. It stopped when click the button of "continue program execute".

Btw, it works around this way: Calling marqueeLabel.restartLabel() in the ViewDidAppear of ViewController A.

cbpowell commented 6 years ago

So I think you're experiencing a known issue/effect, in that MarqueeLabel by itself can't always accurately detect when its container view is presented or dismissed. But if I'm understanding you correctly, it actually works better in iOS 11?

Your workaround is the right way to handle it: manually trigger the scroll at the appropriate time for your app. You could also use the triggerScrollStart function, or any of the convenience methods as described in this section of the Readme.

Let me know if I'm misunderstanding your issue somehow!

cbpowell commented 6 years ago

Going to close this one for now - it's a known "issue" but MarqueeLabel provides you the tools to manually control the label when it's unable to do so itself. Please comment back if you think there's a solution that fixes it though!

iTofu commented 6 years ago

@cbpowell Hi, I also have the same problem. Specifically, if you swipe back more quickly, you will get this bug. And this bug is very stable on iOS10.

iTofu commented 6 years ago

@Jenus Hey, did you fix this bug?

iTofu commented 6 years ago

@Jenus "Calling marqueeLabel.restartLabel() in the ViewDidAppear of ViewController A." works for me, thank you!

cbpowell commented 6 years ago

@iTofu Sorry I meant to reply yesterday but got distracted - using restartLabel() like you figured out is probably the best way to guarantee it starts scrolling again. MarqueeLabel tries to automatically restart as best it can, but it's "just" a UILabel subclass so by itself it doesn't necessarily get automatic notification of when view controllers appear and disappear. The group of functions like restartLabel() are intended to help make things work the way you intend.

Glad you found a solution! I'll take another look to see if there's a solution to this issue when I get a chance too.

iTofu commented 6 years ago

@cbpowell You are too polite, and thank you for maintaining this repo 👍