Search code examples
iosswiftuiwebview

Is a UIWebView the best way to display formatted text in iOS?


I want to display formatted text in my iOS app and I have a lot of it (about as much text as a medium sized wikipedia entry) is a WebView with html the best way to display formatted text or is there a better way? I read on stackOverflow that WebViews suck a lot of memory, is that true? How does wikipedia display all of its text in its iOS app?


Solution

  • The main reason you should use UITextView or UILabel to display formatted text is that there is no ultimate way to get content bounds at the first time it is drawn in UIWebView.

    You can use UIKit object whichever you can render NSAttributedString such as UITextView or UILabel.

    If your content is html you can convert it to NSAttributedString.