I encountered a problem of webview and I thin many people had met that.
In my app, I have an UITableview and each cell of the tableview is self-defined. In each cell a UIWebview is embedded. I need to display each cell’s content when I scroll my tableview. (webview’s loadsHTML and image_url is from an local array)
Problem is that the UIWebview in each cell loads a remote image url and when user scrolls so fast the table, the webview in the cell can not reac fast enough so the webview may display the repeated image for less than 1 second. (Since I use reusable cell and webview loads from image_url array, so that
image_url = [array_image_url objectAtIndex:[index row]];
For user experience, that is terrible to see the repeated images. I tries to figue it out but still can’t. Can anyone help me on this issue?
PS: If possible, I don’t want to cache image on disk
I have had a similar problem (I was displaying remote images) and used the
UIScrollViewdelegate methods (UITableViewinherits fromUIScrollView) to handle when to update my images or not. You can do something similar to load content when the scrolling is stopped:EDIT – Forgot the method that actually loads the rows. This might help 🙂
Note – Some of this code is specific to my app, you will need to adapt to suit your data and web location of the image. Also – the setImageWithURL method is part of the AFNetworking library. If you haven’t checked out AFNetworking, it rocks. If you aren’t already using AFN and don’t need to, then I also added a class I wrote that uses blocks to async load web images.
Alternative method instead of AFNetworking:
WebImageOperations.m: