How to unload an ImageView

You must Login before you can answer or comment on any questions.

Hello,

I'm working on a project which has a lot of images displayed on several ImageViews inside Views which are in a ScrollableView component. So I have pages with a lot of ImageViews. I start loading the images when the user is approaching the page the image is on. When I'm at page 15 or something and I scroll back, the iPad (1) crashes because it runs out of memory.

All the images are 1024*768 (but displayed smaller). How do I (in an elegant way) unload the ImageViews which are not visible to the user and be able to load them again when the user is able to see it.

Thanks for tips :)

3 Answers

Accepted Answer

You can remove image view from view which have no longer use in this way:

view.remove(imageView);

Yes, I know that. But then I have to add/remove/add/remove it again when the user should see it. And that feels very slow on the iPad 1. Allready tried this, but maybe it is the best solution...

— answered 10 months ago by Gertjan Smits
answer permalink
3 Comments
  • Try caching images. Increases the performance a lot.

    — commented 10 months ago by Sahil Grover

  • Images are cached in the caches folder. I think this actually works pretty okay now (the removing and adding), I haven't had any crashes even though I'm looking at 15+ pages with each at least 5 images (1024x768) on them. I added a small fade when there added again which takes away the 'slow feeling'.

    Too easy, but thanks :-)

    — commented 10 months ago by Gertjan Smits

  • Hi, which solution did you find.. i have the same problem and i dont want to remove/add/remove/add

    i have a scrollView which contains photos and i want to unload invisible photos but without removing them....

    please see this link : http://developer.appcelerator.com/question/145602/scrollview-which-contains-137-photos-crashes#comment-150395

    thanks.

    — commented 6 months ago by Djamel ZAHAL

I ended up with a custom wrapper component which has a view and the imageview. I gave the component a custom blur/focus function which adds/removes the image from the parent view. Works pretty well I think.

Your Answer

Think you can help? Login to answer this question!