I have a "product details" UIViewController
on my storyboard which has a UIWebView
to display "rich text" (basically bold and italic). The web view is loaded using a string (fetched from CoreData
) loadHTMLString
. The problem is that the first time the view is displayed, there is at least a one second delay before the web view is rendered. Further "product details" views that are loaded all load fine. It is only the first "product details" web view which takes the time to load.
This is what I have tried (with no joy)
UIWebView
with text on the first screen (to warm up the UIWebView)init
the web view in the prepare for segue
method and pass it to the "product details" view controller.I would be very interested if others have had this problem and how they got over it / worked around it. I find it strange I have not been able to find many similar problems on SO; I must be doing something stupid...
Note, I am using a UIWebView so I can display rich text. I understand I can display rich text using other controls, but the program that makes the text that I want to display can only export rich text using HTML.
This is a common problem for UIWebView
. My workaround is to make the web view initially hidden (showing some sort of "Loading..." indicator instead), then make it un-hidden in the webViewDidFinishLoad:
method.
Instead of use an UIWebView to display rich text content, you can try use OHASBasicHTMLParser of OHAttributedLabel which is backwards compatible with versions prior to iOS 6.
You can find an example of its markup parsers here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With