美文网首页
webview在cell中自适应高度

webview在cell中自适应高度

作者: 夏日里的夏天 | 来源:发表于2016-09-05 16:10 被阅读45次

1.加载HTML标签的,纯文字的,加上这段代码就可以搞定了。

cell.textLabel.numberOfLines= 0;

NSAttributedString*attrStr = [[NSAttributedStringalloc]initWithData:[htmlTxtStrdataUsingEncoding:NSUnicodeStringEncoding]options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType}documentAttributes:nilerror:nil];

cell.textLabel.attributedText= attrStr;

cell.textLabel.font= [UIFontsystemFontOfSize:15.0f];

html标签数据 html标签效果图

2.加载html数据,图文结合的那种。

我在demo里用text文本加载了html数据标签,但是图片没显示出来,我自己的项目用数据源加载时没问题,如果你们用的话,可以用自己的数据源来试试看。

html数据图文结合效果图

github地址:https://github.com/shmily1119/WebviewAdaptionCell

https://github.com/shmily1119/WebviewAdaptionCell

相关文章

网友评论

      本文标题:webview在cell中自适应高度

      本文链接:https://www.haomeiwen.com/subject/rbmrettx.html