Comments (4)
I'm not seeing the issue as you describe it, although I don't see any downside (at a first glance) to making the change. Could you post a bit more of your code? Like how you're setting up the label and where exactly you set it to @""
the first time? Also setting the labelText to [NSString string]
is actually the same as setting it to @""
(because [[NSString string] isEqualToString:@""] == YES
)
from marqueelabel.
Ok..let me give you an example:
I have the following code in viewDidLoad:
_label = [[MarqueeLabel alloc] initWithFrame:CGRectMake(30, 100, 100, 30) duration:5.0 andFadeLength:25.0];
[_label setText:@""];// initially no text should be displayed
[_label setBackgroundColor:[UIColor yellowColor]];
[self.view addSubview:_label];
where _label is an instance variable.
Then I have an UIButton and the corresponding IBAction (on UIControlEventTouchUpInside event):
-
(IBAction) dummyButtonPressed:(id)sender
{[_label setText:[[_label text] stringByAppendingString:@"M"]];
}
If self.labelText is set to nil (as currently is: self.labelText = nil in - (void)setupLabel method from MarqueeLabel), then the line of code [_label setText:[[_label text] stringByAppendingString:@"M"]]; has no effect --> no text is displayed no matter how many times I press the button...BUT if you change the self.labelText = nil; to self.labelText = [NSString string]; (in - (void)setupLabel method from MarqueeLabel.m) everything works as expected.
Hope now everything is more clear..
Regards,
Calin B.
from marqueelabel.
Ah, gotcha, I see what you mean - the problem is showing up because of using the stringByAppendingString:
method on [_label text]
. The property text
just returns self.labelText
, which at that point is nil so stringByAppendingString:
does nothing.
Good catch, thanks! The latest commit should fix your problem, although I'm using self.labelText = @""
just so it's explicitly obvious it's being set to an empty string in setupLabel
.
from marqueelabel.
Glad to help.
from marqueelabel.
Related Issues (20)
- Subclassing and Superclass problem [class NewLabel: MarqueeLabel] HOT 1
- When will scrolling up and down multi-line text be supported? HOT 1
- MarqueeLabel scrolling animation is paused HOT 3
- Fixed duration for variable length of string HOT 1
- Symbol(s) not found for architecture x86_64 when add MarqueeLabel via SPM HOT 1
- MarqueeLabel won't scroll when it is used on UIWindow HOT 1
- Not an issue, just a question about changing text while scrolling HOT 1
- How to wrap MarqueeLabel with using SwiftUI? HOT 1
- Randomly i get a crash in updateAndScroll function HOT 5
- how can I use MarqueeLabel in Swift Package Manager? HOT 1
- Documentation is no longer accessible HOT 1
- How to make a sequence repeat infinite times ?
- Auto Scrolling Paused HOT 3
- Scrolling doesn't start on custom UIView HOT 1
- adding scroll from bottom to top HOT 1
- Please bump iOS version in podspec to 14.0 HOT 1
- Too low iOS deployment target for Xcode 14 HOT 1
- Larger text sizes / maximumContentSizeCategory HOT 5
- Privacy Manifests HOT 8
- Support up and down and custom view, such as with an avatar
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marqueelabel.