how to force a refresh of a UIWebView?

I have a window, and then a subview containing a UIView, then another subview which has a subview of a UIWebView control. I load text into the UIWebView control, and it doesn't get refreshed on the screen. I tried calling


[my_uiwebview setNeedsDisplay]


and that did nothing to help.
I am loading the uiwebview with data via loadData: MIMType: textEncodingName: baseURL:, and it seems to process the data synchronously, as immediately after the call to loadData, the .loading field shows 0.

during development I was testing the uiwebview control, and when I had it directly attached to the windows as a subview (not in two other layers), it showed new data on screen on every load without a problem, but now that it is two layers down in terms of subviews, I never see a refresh.

Boy am i frustrated, a prize to whoever helps me! I sure could use some help on this super frustrating issue. I click NEXT in my program and nothing gets drawn!

1024 processor Connections Machine, Mac OS X (10.5.4)

Posted on Sep 19, 2008 9:21 PM

Reply
6 replies

Sep 19, 2008 11:41 PM in response to hard_wurker

FURTHER INFO:

I am actually rending two different UIWebView objects, and when I render the 2nd one it fouls up the first; evidently either UIWebView has some tricky timing issues which when you issue two at once you get an intermittent bug, or there is some perhaps restriction where you gotta wait for it to finish rendering before starting up a second one, else bad things happen. I am loading simple strings into the UIWebView control, so render time is basically instantenous, but something is REALLY NASTY down there, maybe somebody else has wrestled with this!

Sep 24, 2008 8:26 PM in response to jerbeers

Yep, this is obviously a bug, apple made the WebView system non-reentrant so that if you try to do more than one at a time it craps out. Too bad, it means preloading things for the user is not such a good idea. It also means that if a page is loading very slowly you have to wait before starting a new page, which means lots of extra async. logic, this is going to bite a lot of developers in the *** because it will create bugs which depend on what web page is being loaded, and various other latencies. I am ducking the issue for now by only rendering one page at a time, but gosh I hope I don't forget about this bug down the road...

Sep 27, 2008 1:56 PM in response to hard_wurker

Has anyone found a workaround for this problem? I'm having a very similar problem that I need to fix. I have a hierarchy of list views that I eventually drill down to a WebView. When I return to the list view and then go to another WebView and back to the list view again, the app locks up. So it's something like this:

LV1 = 1st level list view
LV2 = 2nd level list view
WV = webview

LV1 -> LV2 -> WV -> LV2 -> WV -> LV2 (screen locks up)

Any ideas?

Sep 30, 2008 10:48 AM in response to sabernar

UIWebView doesn't support concurrent use, so if the previous page is still loading somehow, and you fire up a new render then it will do bad things. So you have to wait until the previous view is done, by receiving the done message (i forget the delegate method that is called), then you can go forward. obviously they have bugs in their code, with their safari system they only tested one view running at a time.

Oct 10, 2008 3:43 AM in response to hard_wurker

Hi,

i have 3 webviews in 3 different views and i loaded the webview one after the other, that is when the first is loaded i'm loading 2nd webview and when 2nd is loaded , loading 3rd webview.. still i can see 1st webview only , but when i make it as infinite loop (means webviewDidFinishLoading() is called many times for each webview) all 3 webviews are loaded. how to overcome this problem. any solution?

Regards
sujatha

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

how to force a refresh of a UIWebView?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.