5

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

Atef
  • 2,872
  • 1
  • 36
  • 32

3 Answers3

3

also try the following

[sellerImage setImageWithURL:[NSURL URLWithString:[productPicture stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]
                placeholderImage:[UIImage imageNamed:@"placeholder.png"]
                         success:^(UIImage *image, BOOL cached) 
        {
            dispatch_async(dispatch_get_main_queue(), ^{
                sellerImage.image = image;
            });
            NSLog(@"success Block");
        }
                         failure:^(NSError *error) 
        {
            NSLog(@"failure Block");
        }];
Ahmed
  • 938
  • 7
  • 16
1

try the following

UIImageView *sellerImage = [[UIImageView alloc]init];            
[sellerImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:
[productPicture stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
Ahmed
  • 938
  • 7
  • 16
0

Assign a placeholder image properly.. issue with me was with wrong image extension that doesn't match with each other i.e. placeholder.jpeg and palceholder@2x.jpg

Baig
  • 4,737
  • 1
  • 32
  • 47