Why my tableview is slow?

后端 未结 5 678
不思量自难忘°
不思量自难忘° 2021-01-26 16:50

im making a tableview loaded with some NSArrays, the cell contains two labels and a background image view loaded with a URL image. The problem is that the scrolling of the table

5条回答
  •  天涯浪人
    2021-01-26 17:08

    You are calling [NSData dataWithContentsOfURL:[NSURL URLWithString:_ImageUrl[row]]] from cellForRowAtIndexPath , which is not good idea. Because it'll go to the server every time a UITableViewCell is loaded.

    You must use Asynchronous image loading & cache. These libraries might help you : (My personal favourite is SDWebImage)

    1) https://github.com/rs/SDWebImage

    2) https://github.com/nicklockwood/AsyncImageView

    And more, you can refer to the sample code by Apple about LazyTableImages - https://developer.apple.com/library/ios/samplecode/LazyTableImages/Introduction/Intro.html

    UPDATE:

    For SDWebImage follow this guide. It's very good.

    http://iosmadesimple.blogspot.in/2013/04/lazy-image-loading.html

提交回复
热议问题