Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to show image in UITableViewCell with DTCoreText
    primarykey
    data
    text
    <p>I have <code>DTAttributedTextContentView</code> in UITableViewCell and try to load it with html (with image), but can't find a proper way to do this. I have look into <code>DemoTextViewController.m</code> in Demo which have image load with </p> <pre><code>- (void)lazyImageView:(DTLazyImageView *)lazyImageView didChangeImageSize:(CGSize)size { NSURL *url = lazyImageView.url; CGSize imageSize = size; NSPredicate *pred = [NSPredicate predicateWithFormat:@"contentURL == %@", url]; // update all attachments that matchin this URL (possibly multiple images with same size) for (DTTextAttachment *oneAttachment in [_textView.attributedTextContentView.layoutFrame textAttachmentsWithPredicate:pred]) { oneAttachment.originalSize = imageSize; if (!CGSizeEqualToSize(imageSize, oneAttachment.displaySize)) { oneAttachment.displaySize = imageSize; } } // redo layout // here we're layouting the entire string, might be more efficient to only relayout the paragraphs that contain these attachments [_textView.attributedTextContentView relayoutText]; } </code></pre> <p>But I don't know how this will apply to UITableViewCell I tried</p> <pre><code>- (void)lazyImageView:(DTLazyImageView *)lazyImageView didChangeImageSize:(CGSize)size { NSURL *url = lazyImageView.url; CGSize imageSize = size; NSPredicate *pred = [NSPredicate predicateWithFormat:@"contentURL == %@", url]; for (UITableViewCell *cell in self.tableView.visibleCells) { if ([cell isKindOfClass:[CommentCell class]]) { CommentCell *cc = (CommentCell *)cell; for (DTTextAttachment *oneAttachment in [cc.attributedTextContentView.layoutFrame textAttachmentsWithPredicate:pred]) { oneAttachment.originalSize = imageSize; if (!CGSizeEqualToSize(imageSize, oneAttachment.displaySize)) { oneAttachment.displaySize = CGSizeMake(300, 100); } } [cc.attributedTextContentView relayoutText]; } } } </code></pre> <p>But the cell height not show correctly and the image isn't resize to fit <code>DTAttributedTextContentView</code> size. I can't find any document of how to implement this.</p> <p>If you have a better choice or solution, please tell me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload