简体   繁体   English

如何在iOS共享Gmail应用中显示HTML正文?

[英]How I can display a HTML body in iOS shared Gmail app?

I try to implement in iOS -- UIActivityViewController Gmail share subject and body, my body is in HTML format and for some reason Gmail application don't format and display this HTML, I'm getting a basic text :( 我尝试在iOS中实现 - UIActivityViewController Gmail共享主题和正文,我的身体是HTML格式,由于某种原因Gmail应用程序不格式化并显示此HTML,我得到一个基本文本:(

Something like: 就像是:

<html><body style='white-space: pre-wrap;'><div
 style='font-family:verdana;font-size:10pt;'> .....

How I can display a HTML body in iOS shared Gmail app? 如何在iOS共享Gmail应用中显示HTML正文?

Prepare your html string to NSAttributedString object rest it will take care for gmail app body. 准备你的html字符串到NSAttributedString对象休息它会照顾gmail app body。

NSAttributedString *strMessage = [[NSAttributedString alloc] initWithData:[yourHtmlString dataUsingEncoding:NSUTF8StringEncoding]
                                             options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
                                                       NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)}
                                  documentAttributes:nil error:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM