0

I have few questions regarding loading images to tableviews;

I am using ASIHTTPRequest.

1.) I have a tableview, and i need to load images to it. I have images which has the size of 100KB, 180KB, 450KB, and 2MB. I know that these images are too big, but i have no control over this. I am forced to load these images in the tableview. When i do this, it slows the scrolling, and slows to switch from views to views. So how can i prevent this ? any solution?

2.) Presently i am using SDWebImage, i am not satisfied with this library because it slows the scrolling etc (even when i use images which is less than 110kb) I need a library that can perform faster actions ?

Illep
  • 16,375
  • 46
  • 171
  • 302

2 Answers2

1

You may have to downsample the image to the image view size in the background before displaying it. It will definitely cost you a lot of CPU cycles upfront, but will speed up scrolling. I recommend the ImageIO framework because it has no issues running in non-main threads.

Costique
  • 23,712
  • 4
  • 76
  • 79
  • Is this the best approach ? Could you post a link to an example project that has used ImageIO framework, so i could undestand it better. – Illep Jan 31 '12 at 18:10
  • 1
    This may not be the best approach in your particular case, but you should try it out to see how well it works for you: http://stackoverflow.com/questions/5860215/resizing-a-uiimage-without-loading-it-entirely-into-memory – Costique Jan 31 '12 at 18:16
0

I don't think it's SDWebImage that is slowing your scrolling down. SDWebImage downloads the image in a separate thread, the only thing it really does on the main thread is place the image in the UIImageView and this has to be done on the main thread. I use SDWebImage in a few different UITableViewCells and I have been able to achieve smooth scrolling.

2mb is really large -- you are not going to be able to load that image into a UITableViewCell without seeing some jerk. The fact is that it takes some time for the UIImageView to render that image.

If I were you I would run your app through the Time Profiler instrument and see if you can figure out which lines of code are taking the longest to run in your UITableView or your UITableViewCells.

Michael Frederick
  • 16,664
  • 3
  • 43
  • 58
  • Yes, i will try what you suggested. Can you tell me the maximum size of an image allowed (best option) to display in a tableView ? – Illep Jan 31 '12 at 17:52
  • I can't tell you the maximum size, you would have to use trial and error to figure that out. The smaller the better! – Michael Frederick Jan 31 '12 at 18:01