PFImageView on UITableViewCell choppy scroll

79 views Asked by At

I'm using a custom cell on a tableview and I have a PFImageView background image outlet (from Interface Builder).

When I'm scrolling the table and the cell's background image that's about to appear is the first time loading (no caché involved), it produces an annoying jump visual effect.

This weird effect doesn't produce when the image is already cached. I use this code snippet to load the image async:

_ivBackground.image = nil;
_ivBackground.file = recipe.photo;
[_ivBackground loadInBackground:^(UIImage *image, NSError *error) {
    if (!error) {
        [UIView transitionWithView:_ivBackground
                          duration:0.2f
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        animations:^{
                            _ivBackground.image = image;
                        } completion:NULL];
    }
}];

I notice that this effect occurs when loading images bigger than 200kb.

Is there any other solution to avoid this strange behaviour?

Thank you.

1

There are 1 answers

0
deadbeef On

Thats because PFImageView already sets the image (without animation). If you want a custom animation, maybe you should implement your own UIImageView subclass.

Alternatively you can try to call _ivBackground.image = nil; just before your animation call (I haven't tried).

[_ivBackground loadInBackground:^(UIImage *image, NSError *error) {
    _ivBackground.image = nil;
    if (!error) {
        [UIView transitionWithView:_ivBackground
                          duration:0.2f
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        animations:^{
                            _ivBackground.image = image;
                        } completion:NULL];
    }

}];