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...
a开发者_高级运维ny help on this?
I found this article very helpful. It provides a very detailed example for lazy loading of images in the main runloop.
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.
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
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.
精彩评论