4

I have an infinite carousel made of UIWebViews. On every swipe, one UIWebView gets removed (ARC) and one gets built. On the main thread, the UIWebViews are populated with html by calling loadHTMLString:baseURL: on the UIWebView instance.
Most of the time it works as expected: the html gets its layout from css- and js-scripts. But sometimes it fails and the html is presented without styles. (Sometimes it is shown with styles but without fonts loaded with @font-face.)
css- and js- files definitely exist and are to be found in the folder offered under baseURL.
It seems that this behaviour occurs more often on iPad3 and more recent devices than on older devices. And it occurs more often on building the whole carousel than on pure swiping.

UPDATE: Usage of loadData:MIMEType:textEncodingName:baseURL: instead of loadHTMLString:baseURL:seems to reduce unexpected behaviour. I'd appreciate any hint in which direction to look for the bug.

1
  • I'm struggling with this problem too, have you found a solution to this? Would appreciate your insight! Commented Mar 26, 2017 at 23:15

1 Answer 1

0

One thing you could try is loading the HTML first, and when the page has rendered, inject the stylesheet and JS scripts programmatically using [UIWebView stringByEvaluatingJavaScriptFromString:(NSString *)string]. This question has good examples of this. This will at least let you break the issue down, one step at a time.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.