Images are Jumping in UITableView

PrabhakarRayPrabhakarRay GBMember ✭✭

Hi All,

I have a UITableView with a custom cell, where I have one image and couple of labels. Overall structure is that there is a custom cell class and a data source class. I have an update cell method in the custom cell class where I pass all the values to update the cell image and labels. For updating the image, I download the data from an image url asynchronously. In the GetCell method in the data source class, I pass all the required data to UpdateCell method.

When I scroll trough the list images kind of jump from a cell to another which leads to wrong images in different cells. I understand the reason this might be happening but I'm not getting a solution to this problem. I tried implementing a mechanism to cancel the asynchronous calls using cellDisplayingEnded method, but the problem is that I can override this method in data source class only but I'm making asynchronous calls in custom cell class.

I also tried calling calling the UpdateCell method based on willDisplay and CellDisplayEnded methods, but it didn't help.

Can anyone help me find a solution to this problem ?

Answers

  • iphooiphoo BYMember ✭✭
    Try to cancel your async request in `UITableViewCell.PrepareForReuse` method. This way your can encapsulate image loading logic in your custom cell.
Sign In or Register to comment.