Displaying Lots Of RichText : Choosing the best option

后端 未结 2 1583
粉色の甜心
粉色の甜心 2021-01-31 11:06

What is the best way to display lots of RichText (HTML formatted)

At the moment I\'m working on an app for a forum. As you\'d expect the posts

2条回答
  •  借酒劲吻你
    2021-01-31 11:10

    So if I am reading this right, you want the forum posts of a given topic to be cells of a UITableView and the cells need rich formatting?

    Assuming this is correct, I imagine each post will take up a lot of the screen (large cell height). In this case, having a UIWebView as a subview might not be as bad performance-wise as you might think. UITableView reuses cells so really only the visible cells need be loaded into memory.

    I'm also assuming you are able to access the forum via an API, right? In which case, you should be able to pre-load data immediately prior to loading the view and the UIWebViews will only be used for formatting. You can even load a CSS file from your app bundle when you loadHTMLString into your UIWebView so you're not loading that from a server every time.

    All that being said, if you did have a lot of concurrently visible cells it might be a different story and I'd maybe consider only showing plain text in the UITableView index and displaying the rich formatting only when the user taps the cell to view the single post. This might also be better from a design standpoint as having a ton of differently formatted cells on screen could potentially end up looking a bit sloppy.

    Also, this may be obvious (especially since you seem to be both performance and design conscious) but please don't use UIWebView for UI controls. Any time I see a UIWebView tab bar or fake navigation bar I cringe (ack, Netflix). For formatting though, a lot times it's the only way to fly if you're loading a lot of dynamic content from a server.

提交回复
热议问题