Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何允许在UIWebView中呈现HTML?_Iphone_Html_Uiwebview - Fatal编程技术网

Iphone 如何允许在UIWebView中呈现HTML?

Iphone 如何允许在UIWebView中呈现HTML?,iphone,html,uiwebview,Iphone,Html,Uiwebview,我有一个UIWebView,其中我显示了一个数组中的某个对象(在本例中是一个电子邮件正文)。我使用以下代码执行此操作: NSString *string = [messages objectAtIndex:count-row-1]; NSString *string2 = [string stringByReplacingOccurrencesOfString:@"\n" withString:@"<br/>"]; [self.webView loadHTMLString:str

我有一个
UIWebView
,其中我显示了一个数组中的某个对象(在本例中是一个电子邮件正文)。我使用以下代码执行此操作:

NSString *string = [messages objectAtIndex:count-row-1];
NSString *string2 = [string stringByReplacingOccurrencesOfString:@"\n" withString:@"<br/>"];


[self.webView loadHTMLString:string2 baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
isHTML
是否将
BOOL
设置为
NO
,我不知道这是否有问题

我现在已经尝试将
isHTML
BOOL
设置为
YES
,它解决了一半的问题。现在,一些(大多数)格式显示(CSS/图像/富文本),但不幸的是,在一些消息的中间,我得到了这样的标签,在没有的地方:

style="margin-bottom: 15px; width: 570px; text-align: left; margin-left: auto; margin-right: auto;" 

我做错了什么?

考虑
CTCoreMessage
上的方法,而不是
body preferring plaintext:
,后者在可能的情况下更喜欢纯文本。如果您故意提取邮件正文的纯文本版本,您将永远看不到格式。

您所说的“邮件未正确显示”是什么意思?我试图发布一张图像,但没有足够的声誉。基本上,它忽略了所有的格式/图像/CSS,只显示消息中的文本?纯文本?HTML?从一条不起作用的消息中发布一些示例代码!我已尝试将BOOL设置为YES,请查看我的更新问题。好的,但不会选择纯文本:如果设置为YES,则返回相同的值?否。阅读并了解“输出参数”。好的,我想我现在明白了。因此,不要将bodyPreferringPlaintText添加到数组中,而是将msg.htmlBody添加到数组中。这是正确的吗?
style="margin-bottom: 15px; width: 570px; text-align: left; margin-left: auto; margin-right: auto;"