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.
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
UITableViewcould be a solution, but I think,UITableViewis for the typical iPhone table, adjusting and customizing it and itsUITableViewCellsisn’t worth it, if the only reason is memory usage.I’d go with
UIScrollViewand react upon the delegate’s methods to load new content and drop old one. If you want a non-pagingUIScrollViewyou should usescrollViewDidScroll, which is fired really often, so maybe there will be need for another optimization – test it. A pagingUIScrollViewseems to be easier to me. Just react onscrollViewDidEndDeceleratingfor loading and dropping content.Hope that helps.