I’m coding an application on Ipad, in a certain point of my application I present a ViewController with the presentModalViewController.
My ViewController is a UISScrollView who take the larger of the modalView and inside it I display some images, I allow pagingEnabled so I can see all my images inside the scrollView.
Sometimes I have to display more than 10 images inside the scrollView, so I have this error
RECEIVE MEMORY WARNING LEVEL=1 after this one RECEIVE MEMORY WARNING LEVEL=2 and finnaly the debugger exited due to signal 10 (Sigbus).
What can I do? is there a way to unload the image thats offscreen? or others things to do?
Thanks,
I guess you’re adding all the images to the
UIScrollView? Then the iPad has to keep all 10 images in memory. If they are full screen images, each of them will take up about 3 MB of memory, so you’re using 30MB just to keep the 10 images in the scroll view.You should only add the one or two images that are actually visible. Once they scroll out of sight, remove the
UIImageViewfrom yourUIScrollView(and make sure you don’t retain it anywhere else so it can be deallocated). When a new image scrolls into sight, add it to theUIScrollViewonly then.In your
UIScrollViewDelegatemethod-scrollViewDidScroll:get the currentcontentOffsetand use that to calculate which images are visible.