我想在UITextView中显示网址图片。
服务器映像名称为大写扩展名。
图像名称:asset(8).JPG
图片网址: http://example.com/的资产(8).JPG
我的代码是:
NSString *htmlString=@"<html><img src=\"http://example.com/coil-web/files/nqr330qqcbcptmstpl4/asset(8).JPG\" height=\"100\" width=\"100\"></html>";
NSMutableAttributedString *htmlStringAttributedString=[[NSMutableAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
self.textview.attributedText=htmlStringAttributedString
但它只显示UITextView中带有html名称的白色文件。
获得NSMutableAttributedString,如下所示:
{
NSAttachment = "<NSTextAttachment: 0x7f82f076fb40> \"asset(8).JPG.html\"";
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICTFont: 0x7f82f0774ac0> font-family: \"Times New Roman\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
其图像然后为什么NSAttachment显示资产(8).JPG.html 。是什么.html ??
我的代码适用于小扩展图像名称。我想在文本视图中显示html文本。