iPhone, Store Loads of Photos? - iphone

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 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.

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

Related

deleting image heavy custom uitableviewcells

I have a table which is made from custom UITableViewCells which contains downloaded images.
Ive found the app crashes after too many images are displayed. How can best stop this? I don't mind deleting the first images, but don't know of the best way to do it.
EDIT
How do I write the images to the device for caching?
Post your cellForRowAtIndexPath code. Sounds like you have a problem there. If you're certain you do not, then when you receive the memory warning, release any objects you do not need, and can easily be loaded again if required. These objects may be in other ViewControllers not on screen or ImageView objects already displayed.
Best we can do unless you post code.
Or read Apple's Memory Management Guide.

ScrollView as PhotoViewer, load Images only if needed

I would like to create a PhotoViewer for an iPhone.
For that, I already created a ScrollView with Paging enabled in that I add programmically add the UIImageViews. The problem I see is, that if I would have like 100 Images and I would all add to the ScrollView it would take alot of performance and memory.
How would you make it more performant? I thought about loading the Images of the following 2 pages and releasing the Images after the 2 Images before when scrolling through the pages.
I thought about creating a Subclass of UIScrollView and to name it UIPhotoScroller (or something like that). But I also want to show a UIView in the MainWindow with Information about the Images. Is it possible to make the UIView visible from the Subclass?
You really would help me with that. Thank you in advance :D
Create an NSCache.
When you need a particular image, try to get it from the cache. If it's not there, load it from disk and save it in the cache. The filename is a suitable key.
When you get a memory warning, tell the cache to empty itself.
The cache will release some of its entries periodically, depending on how it's configured. This is a good thing, but you might want to adjust it to have a particular total memory size. Tweak its parameters until it behaves like you want it to. To see your memory usage, use Instruments.
How about doing a UITableView with a single photo per cell. When a cell is being request by the data source, you display a spinner and have a queued NSOperation load the image and refresh the row when done.
You can control the amount of concurrent ops with a NSQueue, so you have complete control on performace/responsiveness. You can then remove old cached images when low on memory/paging, etc.
There are solutions to horizontal UITableView if you need horizontal scrolling.
Have you looked at the three20 library? There's an example of creating a great Photos app-like viewer of photos, and it's pretty easy to work with the three20 library.
Hope this helps!

App like default photo browser in iphone?

i am developing a app which contains feature like default photo browser in iphone. I done some what similar to that. but after loading some(near about 10-15) images from remote server,i am receiving memory warning.My requirement is loading image one by one. For this, on scroll view i am putting an images and increasing the contentSize of scroll view. it will work fine. but due to memory warning app quite.
Guys, any have any idea to approach for this feature which work similar to photo app without problem?
thanks in advance .
You're running out of memory because you're keeping the data for 10 or more images in memory at one time. You need to have more logic in your code that not only preloads and increases the scroll view's content size, but also removes UIImageViews from the scrollview (and thus from memory) as the user scrolls to newer stuff. (You can also save "evicted" images to the cache area on disk so if the users scrolls back you don't have to go to the server again.)
If you use a UITableView, it will request the images only when needed, and will automatically purge off-screen cells to save memory. It may not fit into the aesthetic for your application, though.

Preloading images from URL in TableViewCell

I'm making a simple rss reader for the iPhone. The feed (http://feeds.feedburner.com/foksuk/gLTI) contains a reference to images that I want to show in my TableView.
By default, as far as I understand, the iPhone only tries to load images when they are needed: it will only load the images for the rows that are displayed. Only when the user scrolls down, it will start loading the ones that need to be displayed. Right?
Now, since the images are downloaded from the web (they are not too large, but still), the scrolling of my TableView is stuttering. This is in the emulator, so on the device itself it will only be worse.
Luckily, this specific feed only lists the latest 12 entries of the blog. So I guess I should be able to first download an cache all the images, so they can be loaded from the memory, rather than from the URL.
What is the proper approach here?
I had the same problem, where my TableView would have to download each image before it displayed the cell. Like you say, it causes a big slowdown in the scrolling speed. What you need to do is download the images in the background and then insert them into the cell when they're finished downloading. This is how the app store app does it.
This post has all you need to know, including a class file you can use straight away:
http://www.markj.net/iphone-asynchronous-table-image/

Better way to have a photo slider/thumbnails on iPhone?

I have a probaly large list of images and want something like the photo app but with custom toolbar.
I wonder how do this. I see the sample of Apple http://developer.apple.com/iphone/library/samplecode/Scrolling/index.html but that not will work for a large set of images.
I have a product list and some of my customer need download as much as 12,000 products in the device (I have a solution for the PocketPC I'm porting to iPhone).
In this thread How make a view of thumbnails in landscape mode? somebody suggest is possible use a TableView, but then I'm not sure... mainly how hide the section caption then could be...
UPDATED correct the link
The "Scrolling" demo won't work as-is for a large image set, but some minor adjustments can easily fix that. The trick is to use UIScrollView delegate methods to load images on demand and then unload them after they disappear. For decent performance you'd want the central image and one or two on either side to be loaded-- meaning that you can extend that design to support as many images as you like but still never have more than 3-5 in memory at a time.
The Stackoverflow link you post doesn't actually mention table views, so I'm not sure what approach you have in mind there. If by "section caption" you're referring to section header and/or footer text, then just don't provide any. Table views don't have a default for this, so if you don't give one to a table view then it won't show one.