0

Background: I have a UITableView showing an image in each cell. These images are all part of a big pdf-file. So what I am doing is actually rendering little pdf-parts in those UITableViewCells, each cell displaying just one piece. Therefore I add a UIView to the contentview of the cell and render the view on demand. Rendering these pdf-parts is expensive and each takes about 0.2 seconds (only drawing the Pdf-part), which slows the scrolling of the table terrible down.

Idea: Now, I know there may be a solution when I look how UIImage renders URL-based images. If you create a UIImage based on a url, these images are rendered somehow delayed. E.g have a look at the iTunes-App. Smooth scrolling is possible, each image is displayed unrendered and after rendering is finished it appears smoothly.

Problem: How can I render an expensive rendering in a UITableViewCell like described above, by somehow showing the cell delayed? Has anybody an idea, how Apple solved it within UIImageView?

Thanks in advance

Daniel

1 Answers1

0

this is (mostly) duplicate of Lazy load images in UITableViewCell. Check the links and examples there.

In short, what you need is spawning a separate thread for loading the PDF thumbnails, and that thread then signaling back to the main thread with the generated images. This is easily done by using performSelectorInBackground:withObject: and performSelectorOnMainThread:withObject:waitUntilDone: methods.

Community
  • 1
  • 1
Linas Valiukas
  • 1,316
  • 1
  • 13
  • 23
  • Hi thanks for the hint for the duplicate message. I didn't see it. The solution though doesn't satisfy me. Memory consuption is big if you think, how much cache I must build up in _advance_. And my images are as big as the whole screen. I just found a solution, which seems very promising: I use a CATiledLayer! If you delegate drawing in a layer, all the background threading is done by the system. All you need to do is move your drawing from the view to the layer. – user201631 Nov 03 '09 at 19:38
  • Can you provide an example of this? – Jordan Nov 03 '09 at 23:13