In my app I am using a UIWebView for the about screen. I've made the background transparent using
webView.opaque = NO;
webView.backgroundColor = [UIColor clearColor];
But for some reason rarely (1 out of 20) the text in the UIWebView will be inivible. It's still there because the scroll bar is correct and I can also copy text out of it, but you just can't see it. If I disable the transparent background then it's fine.
Did anyone else experience this behaviour?
Update: Just disabled the transparency. It's got nothing to do with it. So actually I've got a UIWebView, where sometimes the text is invisible.
Workaround: I've found a workaround, but I don't know why it works. What I'm doing in my app is preload all UIWebViews during initialization, so that later when I bring up those views, there is no delay. I force the controller to trigger viewDidLoad by calling self.view = self.view. After that the UIWebView which is a subview in my nib is loaded and I can preload the html using
[_webView loadHTMLString:html baseURL:url];
That was my original code for loading html into my UIWebView. Now I've switched to
[_webView loadRequest:urlRequest];
and this always works. Sometimes, when I'm fast enough I can see the text pop into view when it hasn't been fully preloaded yet. With loadHTML it appears that sometimes the text also hasn't been loaded, but the pop-in step won't get executed.
So it seems that preloading with loadHTMLString sometimes can cause the text not being loaded whereas loadRequest will always succeed. Can anyone explain this behavior? I'd be curious what the difference is.