简体   繁体   中英

iOS formatted text

We are in the process of developing a client-server application where we maintain some content and labels in a database on the server side. Our data sent over to iOS application with JSON.

Our challenge is how we should handle formatted text. On the server side, you can create text, for example. Bold, bullet points, etc..

Today we save in HTML format - but have trouble getting it to look nice in our iOS application.

Is there a better way to handle this? What is best practice on the topic?

您可以通过创建NSAttributedString来使用HTML:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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