Does anyone know any good library/tutorial that can do asynchronous image loading for a cell in UITableView? I am looking for a method that doesn't involve too much code changing in my current code and easy to integrate to a regular synchronous UITableView.
Try looking into Three20
An open source library written by the guy who wrote the official "Facebook" app for iOS.
Moreover, the code of the facebook app is based on that library.
If you rather do it by yourself, read MHLazyTableImages, it comes with a github project. It's an adaptation of Apple's LazyTableImages. Or you can use HJCache.
Fully-Loaded is another one which is pretty simple. It's more a generic image view loaded which you can use in custom table view cells.
https://github.com/foursquare/fully-loaded
I quite like SDWebImage, which is an asynchronous image downloader with cache support with an UIImageView category.
https://github.com/brendanlim/SDWebImage
Related
If I would like to have lazy loading like google+ or facebook app (maybe even 9gag), should I go with UITableView or UIScrollView?
The goal is to load whole new set of cells or scrollview pages (not just thumbnail like apple lazyloading tableview). If you have facebook app, try scrolling down fast and you will see what I mean.
Any example would be also helpful.
Thanks.
You should prefer table view for this. with tableview , You can use reusable customcell. tableview can be useful for Auto layout in landscape mode and if app is universal the tableview is more useful.
You can try this: https://github.com/nicklockwood/AsyncImageView. This is a best example for loading images asynchronously. The library can also be used to load and cache images independently of a UIImageView as it provides direct access to the underlying loading and caching classes.
Using Grand Central Dispatch you can do this.
The following link might be useful.
http://www.raywenderlich.com/4295/multithreading-and-grand-central-dispatch-on-ios-for-beginners-tutorial
Take a look at SDWebImage, really easy to use, it support caching and asynchronous loading.
I would use a uicollection view. Here is an example that uses uitableview, but you can take it and modify it a bit to work with a collection view.
http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Introduction/Intro.html
If you would like to use a third party library, I would suggest looking at AFNetworking It's one of the most highly used and has a very easy to use function that extends UIImageView LINK
Also as an FYI, a scrollview is part of a tableview.
Hello guys how apple is loading table view cell image that
doesn't affect scrolling of
table view.How fast it is working. I want to make a table view like that which loads
image directly from URL and it doesn't effect scrolling of UITableview
Lazy Loading is the exact term, which you are referring to. (Apple Technologies uses LazyLoading wherever it can be applicable, whether it's iOS or Mac OS X -- and it gives best user experience, too, as user is not forced to wait)
Apple provides sample source code, which performs similar functionality -- Here is the sample code
Don't get confused with the ParseOperation Class. It is just the separate implementation of the XML Parsing functionality. Though, It is a better approach, You can write it in your own working class (from which you are invoking the connection request.)
Additionally -- Apple has updated this code to use Blocks (GCD).
Hope that will help you...
You dont need to look too far - Apple has this code in the Open - LazyTables.
If you want to know the magic sauce is the launching of bg thread to download images, after the downloads finish in background, then it updates the UI to show the image.
In apple's lazyTableImages project when you first run images appear asynchronusly altough you haven't started scrolling. But in SDWebImage it is not like that. If you don't start to scroll, images don't start to appear. I couldn't succeed to populate LazyTableImages in my project. But i did SDWebImage. So i want to add that functionality as well. Is that possible? I want to download images when new cell is created. I know lazyTableImages does that job but i am not sure that SDWebImages does too. Because when i scroll the table images are already there like they are loaded before.
Thank you for your answers..
Is it possible? Yes. How would you achieve this? It sounds like you should probably look in more detail at both the LazyTableImages sample code and the SDWebImage source. It sounds as if you're maybe just trying to copy/paste a lot of code, and you'll really benefit from understanding how it actually all pulls together and works.
SDWebImage is just a UIImageView category, so is comparativly 'dumb' compares to Apple's sample code, which hooks into the table view's underlying scroll view to detect when you've finished scrolling and load in the cells that are displayed (to make it appear more responsive).
Once you're comfortable with how both those classes are achieving their asynchronous download you'll be in a much better position to start playing around with how they work.
Does anyone know of a good tutorial that shows how to lazy load images in a UITableView? I've searched online but the only one I found that looked like it did what I wanted was hard to follow because only parts of the code were shown and I'm new at this so I didn't understand how to hook everything up.
I suggest you check out the SDWebImage project on github, I use it for my table views when I need to load a remote image into the cells.
https://github.com/rs/SDWebImage
As Daniel suggested SDWebImage https://github.com/rs/SDWebImage, I don't know of any tutorial, but in amongst the KTPhotoBrowser samples there is one that uses SDWebImage that can show you how to do it https://github.com/kirbyt/KTPhotoBrowser/tree/master/src/Sample/Classes/SDWebImageSample
If I remember correctly you need to import and use the SDWebImage UIImageView category and then pass the url to the cell and call
setImageWithURL:[NSURL URLWithString:#"yoururl"] placeholderImage:[UIImage imageNamed:#"placeholder.png"]
when setting the cell image.
I haven't actually followed it, but this one has plenty of positive commentary: http://www.markj.net/iphone-asynchronous-table-image/
Can someone give me one source file working ?
Alternatively you can look at my AQGridView, which can display anything in a grid, using an API similar to that of UITableView.
You might want to take a look at Facebook's Three20, specifically their TTPhotoViewController class.
Update: Other options (possibly more modular and easier to integrate in your project):
https://github.com/mwaterfall/MWPhotoBrowser
https://github.com/kirbyt/KTPhotoBrowser
http://github.com/alanQuatermain/AQGridView (as suggested by Jim)