Why my tableview is slow?

后端 未结 5 727
不思量自难忘°
不思量自难忘° 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:03

    You are blocking the main thread with the following line of code:

    cell.CellImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_ImageUrl[row]]]];
    

    My suggestion would be to use AFNetworking and replace the code with the following:

    [cell.cellImageView setImageWithURL:[NSURL URLWithString:@"http://example.com/image.png"]];
    

    Also, your pointers should start with a lower case letter. For instance, CellImageView should be cellImageView.

提交回复
热议问题