I'm currently hitting an API to get a list of inventory items. Right now I am also downloading all of the photos for all of the items on initial load. What I want to do is load the table view with all of the text (be able to interact with the tableview) and then load the photos in the background and update each row once the photo has been retrieved so that it loads faster. I have all of the URLs of the photos from the API. How would I do this?
Asked
Active
Viewed 59 times
0
-
3You have to implement lazy loading for your `UITableView`, Once the data is is ready, you should update the UITableView right away & for image loading you can use https://github.com/onevcat/Kingfisher type of libraries to lazy load the images on scrolling of table-view. Also follow the post http://stackoverflow.com/questions/28694645/how-to-implement-lazy-loading-of-images-in-table-view-using-swift – Prakash Donga Jan 13 '17 at 03:19
-
Awesome! Thank you, I've been looking for something like this for awhile – jnwagstaff Jan 13 '17 at 04:27
-
@ Prakash Donga Good work Prakash. but you should give your answer in answer section not in comment. I really appreciate your answer. – An Kit Jan 13 '17 at 05:31
-
you can use [Alamofire Images](https://github.com/Alamofire/AlamofireImage) its great. – Umair Afzal Jan 13 '17 at 05:34
2 Answers
1
There are many sdk available for lazyloading. You can use SDWebImage for same.
It will automatically load image into your UIImageView as soon as image download.

Community
- 1
- 1

Nirmalsinh Rathod
- 5,079
- 4
- 26
- 56
1
I am using Alamofire Image for this purpose. Here is a sample code.
After installing its pod, you can do:
cell.yourImageView.af_setImageWithURL(url, placeholderImage: nil, filter: nil, imageTransition: .CrossDissolve(0.5), runImageTransitionIfCached: false, completion: {response in
// if you have activity indicator you can stop it when images is downloaded
//cell.activityIdicator.stopAnimating()
})

Umair Afzal
- 4,947
- 5
- 25
- 50