0

In my app I have a bit where the user can take a photo and it get dropped into a list and the user could technically forever keep adding photos.

So what is the best way of saving, storing and loading the photos the user takes? Taking into account, there could be hundreds. Also, loading them all in at once might not be a smart idea as well, but say have a scroll view, scroll down, and when hitting the bottom it could load say 20 more and then another 20, etc.

Any help, much appreciated, thanks.

Josh Kahane
  • 16,765
  • 45
  • 140
  • 253

2 Answers2

0

use tableview, it will load it manages the memory and jst visible rows are loaded into memory if u use dequecell method

read tableview more here

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html

Saad
  • 8,857
  • 2
  • 41
  • 51
0

Just decide where you want to store the photos, built-in photo library or apps documents folder or both (I'd go with photo library for users's convenience in watching, deleting, synchronizing etc.). If you choose documents folder, don't forget to support deleting ... Disk space is the users problem.

If you choose only to store in photos library and want access the photos later from within the app, you have to save the urls of the saved images. This answer tells you how it works.

Loading the photos in scroll view will need some optimization, i.e. it wouldn't be a good idea to load all photos in memory, but only the visible ones. As another answer says, the re-use of cell in UITableView could be a solution, but I think, UITableView is for the typical iPhone table, adjusting and customizing it and its UITableViewCells isn't worth it, if the only reason is memory usage.

I'd go with UIScrollView and react upon the delegate's methods to load new content and drop old one. If you want a non-paging UIScrollView you should use scrollViewDidScroll , which is fired really often, so maybe there will be need for another optimization - test it. A paging UIScrollView seems to be easier to me. Just react on scrollViewDidEndDecelerating for loading and dropping content.

Hope that helps.

Community
  • 1
  • 1
Kai Huppmann
  • 10,705
  • 6
  • 47
  • 78
  • Thanks for that Kai. What should I be looking at to get photos from the users photo library? Im going to need to save photos, then how would I know which photos had been taken in the app to be fetched back without loosing them in the users personal photos? – Josh Kahane May 09 '12 at 14:32
  • @Josh Kahane Edited my answer with a link to another answer, to answer the question in your comment to my answer ;-). – Kai Huppmann May 09 '12 at 16:11