How do I use a UIWebView in a Table Cell?

后端 未结 7 547
终归单人心
终归单人心 2020-12-09 04:49

I\'m building a table with some text that is HTML, so I am using a UIWebView as a subview of my custom table cells. I already ran into one problem - as I scrolled down in th

7条回答
  •  隐瞒了意图╮
    2020-12-09 05:08

    One way to deal with this would be to use several UILabels, each with different fonts. Then strategically place them within the cell as to make them seem like contiguous text. I've seen this done in a UITableView with very good results.

    Another performance problem may be that you are overiding UItableViewCell and it's init method. This almost always leads to poor performance in a UITableView. Instead just use the regular UITableViewCell instances and add subviews to it's contentView.

    This has been covered extensively by Matt Gallagher's Easy Custom UITableView Drawing.

    Another method described was to use Three20, which can give you styled text as well.

    What you are attempting currently can't be done with UIWebview.

    Preloading won't help: this would slow down the UI when UIWebviews are being rendered offscreen; you should always practice lazy loading on the iPhone.

    Putting UIWebviews in a UITableView will come with a potentially unacceptable performance hit. You will need to use other means to accomplish your goal.

    Unfortunately, NSAttributedString is unavailable in UIKit, which could easily solve your problem.

提交回复
热议问题