Skip to content

Commit

Permalink
Options for HTML
Browse files Browse the repository at this point in the history
Render HTML with options.
  • Loading branch information
Wim Haanstra committed Feb 7, 2014
1 parent 33e3679 commit bfae529
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Core/Source/DTAttributedTextCell.h
Expand Up @@ -47,6 +47,15 @@
*/ */
- (void)setHTMLString:(NSString *)html; - (void)setHTMLString:(NSString *)html;


/**
This method allows to set HTML text directly as content of the receiver.
This will be converted to an attributed string.
@param html The HTML string to set as the receiver's text content
@param options The options used for rendering the HTML
*/
- (void) setHTMLString:(NSString *)html options:(NSDictionary*) options;



/** /**
@name Getting Information @name Getting Information
Expand Down
9 changes: 7 additions & 2 deletions Core/Source/DTAttributedTextCell.m
Expand Up @@ -194,7 +194,11 @@ - (void)setSelected:(BOOL)selected animated:(BOOL)animated


- (void)setHTMLString:(NSString *)html - (void)setHTMLString:(NSString *)html
{ {
// we don't preserve the html but compare it's hash [self setHTMLString:html options:nil];
}

- (void) setHTMLString:(NSString *)html options:(NSDictionary*) options {

NSUInteger newHash = [html hash]; NSUInteger newHash = [html hash];


if (newHash == _htmlHash) if (newHash == _htmlHash)
Expand All @@ -205,10 +209,11 @@ - (void)setHTMLString:(NSString *)html
_htmlHash = newHash; _htmlHash = newHash;


NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding]; NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding];
NSAttributedString *string = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL]; NSAttributedString *string = [[NSAttributedString alloc] initWithHTMLData:data options:options documentAttributes:NULL];
self.attributedString = string; self.attributedString = string;


[self setNeedsLayout]; [self setNeedsLayout];

} }


- (void)setAttributedString:(NSAttributedString *)attributedString - (void)setAttributedString:(NSAttributedString *)attributedString
Expand Down

0 comments on commit bfae529

Please sign in to comment.