gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 06:13:48 24 4
gpt4 key购买 nike

我尝试在 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 应用正文。

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

关于html - 如何在 iOS 共享 Gmail 应用程序中显示 HTML 正文?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36263452/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com