iOS格式的文字

时间:2014-10-31 13:06:44

标签: html ios client-server

我们正在开发一个客户端 - 服务器应用程序,我们在服务器端的数据库中维护一些内容和标签。 我们的数据通过JSON发送到iOS应用程序。

我们的挑战是如何处理格式化文本。 例如,在服务器端,您可以创建文本。大胆,子弹点等。

今天我们以HTML格式保存 - 但在我们的iOS应用程序中看起来很不错。

有没有更好的方法来解决这个问题? 关于这个主题的最佳做法是什么?

2 个答案:

答案 0 :(得分:0)

您可以通过创建NSAttributedString:

来使用HTML
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:yourData options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];

答案 1 :(得分:0)

在UIWebView中显示html应该与在PC上的浏览器中查看相同,除了屏幕尺寸。