我尝试在iOS中实现 – UIActivityViewController Gmail共享主题和正文,我的身体是
HTML格式,由于某种原因Gmail应用程序不格式化并显示此HTML,我得到一个基本文本:(
就像是:
<html><body style='white-space: pre-wrap;'><div style='font-family:verdana;font-size:10pt;'> .....
如何在iOS共享Gmail应用中显示HTML正文?
解决方法
准备你的html字符串到NSAttributedString对象休息它会照顾gmail app body.
NSAttributedString *strMessage = [[NSAttributedString alloc] initWithData:[yourHtmlString dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)} documentAttributes:nil error:nil];