Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when using DTCoreText to display HTML code

Tags:

ios

dtcoretext

I use DTHTMLAttributedStringBuilder of DTCoreText to display HTML code in UITableViewCell. But it has an error. This is my code:

NSDictionary *builderOptions = @{DTDefaultFontFamily: @"Helvetica"};
DTHTMLAttributedStringBuilder *stringBuilder = [[DTHTMLAttributedStringBuilder alloc] initWithHTML:[word[@"name"] dataUsingEncoding:NSUTF8StringEncoding] options:builderOptions documentAttributes:nil];
NSAttributedString *stringAttri = [stringBuilder generatedAttributedString];

cell.textLabel.attributedText = stringAttri;

This is error:

    [__NSCFType lineBreakMode]: unrecognized selector sent to instance 0x7f7f7bd1ba60
2015-06-06 11:16:38.898 PhrasalVerb[786:18798] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType lineBreakMode]: unrecognized selector sent to instance 0x7f7f7bd1ba60'
like image 784
thinhvd Avatar asked Apr 24 '26 01:04

thinhvd


1 Answers

I had the same issue. Turns out I was trying to set the text on a UILabel and not a DTAttributedLabel.

like image 158
Pætur Magnussen Avatar answered Apr 25 '26 14:04

Pætur Magnussen