I am developing a iPhone photo app in which there is one view, where I am showing all the images taken through that app with the help of uiscrollview. First I simply loaded the scrollview with all the present images. But it made the app slow and also caused the crash giving the following warning:
Received memory warning. Level=2
I googled a lot and found that the reason for so may be loading such heavy images all together on a view are resulting in memory warning and crash afterwards. So I opt for the concept of lazy loading.
In which I was just loading the three images one at the center(currently shown to user) and the other two on either sides. I did that in following way:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
pageNum = (int)(scrollView.contentOffset.x / scrollView.frame.size.width);
pageNumber = floor(pageNum);
[self setImages:pageNumber]; //setting three images
}
Now there is no crash, no memory warning but the scroll has become quite rough with lots of jerks.
Please suggest me how to get rid the roughness or to show all the images same as iPhone 's default photo app.
Help is much appreciated.
Note: 1. No of images not known, can be unlimited. 2. Xcode 3.2.6 3. ios sdk 4.3
Please consider the link [link]https://www.dropbox.com/sh/h0vwnhhx1acfcb5/W2TQ638udh The link shows a video in which i have shown a photo scroller with lazy loading embedded. Some times it doesn't loads the images so fast also scrolling has become rough.
this is low memry warning see these threads
iPhone OS Memory Warnings. What Do The Different Levels Mean?