开发者

UITableView very slow scrolling with images from the web

开发者 https://www.devze.com 2022-12-10 06:27 出处:网络
I am loadingimages from a开发者_StackOverflow url it\'s about 20-30 images over http. The UITableView is very very slow sticky.

I am loadingimages from a开发者_StackOverflow url it's about 20-30 images over http.

The UITableView is very very slow sticky.

What can i do to make it smother?


Download them first, then cache them.

If the cell needs to display and the image isn't there yet, have a placeholder image available until the real one shows up.

If it's still slow after that, hook up Instruments and profile it. Instruments will tell you exactly where your code is spending all its time.


I can think of two possibilities:

  1. Are you keeping the entire image in memory and scaling it down when you draw the cell? That will slow things down considerably; consider scaling the image to icon size and discarding the original image. You can always reload it.

  2. UITableViewCells are notorious for being slow if you have more than a couple of subviews. The best solution to this problems is drawing the cell yourself in the cell's drawRect: method.

BJ's placeholder idea is a great suggestion, downloading the image in the background as you can and replacing the placeholders as they complete.

0

精彩评论

暂无评论...
验证码 换一张
取 消