Raju
Raju

Reputation: 451

Loading the image is taking time

I am loading the images from internet to my TableView cell.

But it's taking time to load it to TableView.

One of my friends suggested using threading but I don't know how it will work in iOS and objective C.

Can anyone tell me how to use threading or threading-like concept to speedup the process?

Upvotes: 1

Views: 1072

Answers (4)

Lithu T.V
Lithu T.V

Reputation: 20021

Problem

The problem here is image size is a large and hence it take more time to download ,hence when run in main thread will cause blocking of UI performance.

Solution

Actually the solution is to make the download of images asynchronously (in a separate thread) so that the UI which runs in the main thread, is not blocked

Well there are some good libraries to do the task for you .just drop in and enjoy

  1. AsynchImageView
  2. SDWebimageview
  3. AFNetworking class extension of imageview (if you are using AF this is a good choice)

Upvotes: 1

Xcoder
Xcoder

Reputation: 1807

I think U need to use https://github.com/nicklockwood/AsyncImageView . This utility helps you to load images asynchronously.

See the demo samples as well.

Upvotes: 2

Prajwal Udupa
Prajwal Udupa

Reputation: 860

use lazy image downloading technique. This will ensure that the available content is displayed first and then the unavailable data is slowly fetched as time passes by!!. But be careful if your cells are reusable then the older image will be displayed there. so I would recommend a place holder image till the original image is ready to display.

lazy image loading

Upvotes: 1

lakshmen
lakshmen

Reputation: 29084

Do this tutorial: http://www.raywenderlich.com/4295/multithreading-and-grand-central-dispatch-on-ios-for-beginners-tutorial

Will answers your question as well as you can learn about threading and Grand Central Dispatch(GCD).

Same scenario as you.

Upvotes: 2

Related Questions