hulsizer / YetiCharacterLabelExample

MIT License
350 stars 34 forks source link

Not possible to initialize a new YETIFadeLabel with initWithFrame: ? #1

Closed vittoriom closed 9 years ago

vittoriom commented 10 years ago

I'm building a UIView programmatically and initializing the former UILabel objects through initWithFrame: Then I replaced UILabel occurrencies with YETIFadeLabel, but I get an exception:

2014-09-26 11:17:14.710 Dev[20031:125916] **\* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '**\* -[NSBigMutableString replaceCharactersInRange:withString:]: nil argument'
**\* First throw call stack:
(
    0   CoreFoundation                      0x04caddf6 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x0456fa97 objc_exception_throw + 44
    2   CoreFoundation                      0x04cadd1d +[NSException raise:format:] + 141
    3   Foundation                          0x01368891 -[NSBigMutableString replaceCharactersInRange:withString:] + 126
    4   Foundation                          0x013687dd -[NSConcreteMutableAttributedString replaceCharactersInRange:withAttributedString:] + 395
    5   UIFoundation                        0x08a8f565 -[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:] + 95
    6   Foundation                          0x013aeb5d -[NSMutableAttributedString setAttributedString:] + 91
    7   Dev                                 0x005b23ee -[YETICharacterLabel setAttributedText:] + 334
    8   Dev                                 0x005b4778 -[YETIFadeLabel setAttributedText:] + 152
    9   Dev                                 0x005b1f74 -[YETICharacterLabel setupLayoutManager] + 1044
    10  Dev                                 0x005b1b51 -[YETICharacterLabel setup] + 241
    11  Dev                                 0x005b1676 -[YETICharacterLabel initWithFrame:] + 166

How can I create YETIFadeLabel programmatically?

TomStoermer commented 9 years ago

Same here.

Happens in YETICharacterLabel.m -> - (void)setupLayoutManager -> [self setAttributedText:self.attributedText] -> [self.textStorage setAttributedString:attributedText];

(attributedText is nil)

causing the crash

hulsizer commented 9 years ago

Sorry about that!

zero1zero commented 8 years ago

FYI, this never got pushed to cocoapods.org. For a working version, you still need to use:

pod 'YETICharacterLabel', :git => 'https://github.com/android1989/YetiCharacterLabelExample.git'
natan commented 8 years ago

@zero1zero Thanks for the tip! @android1989, can you please publish a new version? Thanks. :v: