Reputation: 2902
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.
Upvotes: 5
Views: 8641
Reputation: 5005
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 [email protected]
Upvotes: 0
Reputation: 945
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");
}];
Upvotes: 3
Reputation: 945
try the following
UIImageView *sellerImage = [[UIImageView alloc]init];
[sellerImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:
[productPicture stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
Upvotes: 1