Scrolling issue if text gets loaded in viewWillAppear
ArquintL opened this issue · 1 comments
ArquintL commented
I add my text for the scrollLabel in viewWillAppear. For this reason, the AutoScrollLabel is at startup non scrolling and in my case centered. If I add now scrollable content, the mainLabel is still centered and the 2nd label not. For this reason the scrollLabel "jumps" after the animation to the start position.
Here is my fix:
CBAutoScrollLabel.m "-(void)refreshLabels":
...
// if the label is bigger than the space allocated, then it should scroll
if (CGRectGetWidth(self.mainLabel.bounds) > CGRectGetWidth(self.bounds) )
{
CGSize size;
size.width = CGRectGetWidth(self.mainLabel.bounds) + CGRectGetWidth(self.bounds) + self.labelSpacing;
size.height = CGRectGetHeight(self.bounds);
self.scrollView.contentSize = size;
/*******************************************************************/
//This is new:
self.mainLabel.textAlignment = UITextAlignmentLeft;
/*******************************************************************/
EACH_LABEL(hidden, NO)
[self applyGradientMaskForFadeLength:self.fadeLength enableFade:self.scrolling];
[self scrollLabelIfNeeded];
}
else
{
// Hide the other labels
EACH_LABEL(hidden, (self.mainLabel != label))
// adjust the scroll view and main label
self.scrollView.contentSize = self.bounds.size;
self.mainLabel.frame = self.bounds;
self.mainLabel.hidden = NO;
self.mainLabel.textAlignment = self.textAlignment;
[self applyGradientMaskForFadeLength:0 enableFade:NO];
}
...
cbess commented
Try adding it in [viewDidLoad]