2012-01-13 34 views
1

這是參照OHAttributedLabel numberOfLines問題。我創建了一個OHAttributedLabel並設置了attributesText我的應用程序崩潰了。要顯示在標籤上的文本可能是多行,因爲它來自服務器。
這是什麼解決方案?OHAttributedLabel numberOfLines

NSMutableAttributedString* attrStr = [NSMutableAttributedString attributedStringWithString:string]; 
[attrStr setTextColor:[UIColor colorWithRed:0.f green:0.f blue:0.5 alpha:1.f] range:[string rangeOfString:matchingStringPhone]]; 
      label.attributedText = attrStr; 

在第二行發生崩潰。

回答

1

編譯器應該警告你在類NSMutableAttributedString中沒有setTextColor:range:方法。
我至少這樣做。
你的?

可能是你要調用
- (空)setAttributes:(NSDictionary的*)的屬性範圍:(NSRange)人氣指數
???

+0

我評論過它,並在第三行添加以下行之後:[標籤addCustomLink:[NSURL URLWithString:@「http://www.google.com」] inRange:[string rangeOfString:matchingStringPhone]];仍然崩潰。 – Nitish 2012-01-13 18:48:55

+0

你認爲addCustomLink:inRange:存在於UILable嗎?打開編譯器警告!它會拯救你! – 2012-01-13 18:52:46

+0

標籤不是UILabel。它是OHAttributedLabel,它具有addCustomLink:inRange:爲其定義。 – Nitish 2012-01-13 18:55:01

相關問題