Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDWebImage always load the placeholder image not the image from URL

Um using the SDWeb image Here

and these my Code :

        UIImageView *sellerImage = [[UIImageView alloc]init];            
[sellerImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:productPicture]]
                        placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

but it always load the placeholder image only not the image from URL, I've tried to use blocks to make sure if it load's the image or not and it enter to the Success Block which means that SDWebImage can load the image from URL but it doesn't change the place holder image.

These is the code When I tried to use blocks :

            [sellerImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:productPicture]]
                placeholderImage:[UIImage imageNamed:@"placeholder.png"]
                         success:^(UIImage *image, BOOL cached) 
        {
            NSLog(@"success Block");
        }
                         failure:^(NSError *error) 
        {
            NSLog(@"failure Block");
        }];

As I said it always goes in the success Block which means it can load the image from URL but it doesn't change the place holder image.

and these is a screen from my problem.

enter image description here

like image 255
Abo3atef Avatar asked Oct 05 '22 22:10

Abo3atef


1 Answers

try the following

UIImageView *sellerImage = [[UIImageView alloc]init];            
[sellerImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:
[productPicture stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
like image 164
Ahmed Avatar answered Oct 10 '22 02:10

Ahmed