views:

136

answers:

2

Hi All

i am developing a app which contains feature like default photo browser in iphone. I done some what similar to that. but after loading some(near about 10-15) images from remote server,i am receiving memory warning.My requirement is loading image one by one. For this, on scroll view i am putting an images and increasing the contentSize of scroll view. it will work fine. but due to memory warning app quite.

Guys, any have any idea to approach for this feature which work similar to photo app without problem?

thanks in advance .

A: 

You're running out of memory because you're keeping the data for 10 or more images in memory at one time. You need to have more logic in your code that not only preloads and increases the scroll view's content size, but also removes UIImageViews from the scrollview (and thus from memory) as the user scrolls to newer stuff. (You can also save "evicted" images to the cache area on disk so if the users scrolls back you don't have to go to the server again.)

quixoto
Thanks quixoto for good idea. Any sample code for this approach will much better for me PLZZZZZZZZ
sandy
Don't have any handy myself. This is the sort of thing that's very application-dependent. Keep around an array of the "pages" in your scroll view, use it as a queue, and bump off the the least recent one each time you advance.
quixoto
A: 

If you use a UITableView, it will request the images only when needed, and will automatically purge off-screen cells to save memory. It may not fit into the aesthetic for your application, though.

alltom