views:

369

answers:

4

I'm having a problem when scrolling down and up a tableView on iPhone it gets kind of stuck while loading the images i need a method to preload the images so the scroll can be fluid or load the images 'till the scroll event stops...

any help on this?

+1  A: 

Lazy Table Images Sample Code included in iPhone Developer Resources. Check out Photo Locations Sample Code as well. It uses Core Data and "lazy loading" techniques if your image files are stored on the device.

falconcreek
A: 

Not sure about images, but with text I have downloaded JSON files when the view loads, parsed into an array and then loaded the tableview with that array.

Jonathan
+1  A: 

Well, generally speaking, preloading images for table view is a bad idea. Think of a following situation: you have 100 cells, each containing one image. That means you'll have to load 100 images before showing the table, which will have a serious impact on avaliable memory.

The "loading effect" you're talking about can be caused by two things: a) as you have said, the problem with loading images. If so, do it in another thread, and pass the image to main thread when it loads b) You're using images that are bigger or smaller than the given size. This will result in resizing the image when it appears on screen, causing the ugly stop-effect - the solution is to draw images in size which is exactly the same as their size.

Chope this was helpful, Paul

Pawel
+1  A: 

I found this article very helpful. It provides a very detailed example for lazy loading of images in the main runloop.

FRotthowe