I've been using SDWebImage successfully for long. But with iOS8 its crashing when we set image i.e.
[ myImageView setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",@"url"]] placeholderImage:[UIImage imageNamed:PROFILE_HOLDER_IMAGE]];
Is there way to avoid it
Cheers
They have changed setImageWithURL to sd_setImageWithURL for iOS 8.
Try this new syntax,
[myImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",@"url"]] placeholderImage:[UIImage imageNamed:PROFILE_HOLDER_IMAGE]];
First of all setImageWithURL:placeholderImage:
is deprecated, also you must check if your URL string is not null. Try this approach:
NSString *imageURLString;
if (imageURLString && ![imageURLString isEqual:[NSNull null]])
{
NSURL *imageURL = [NSURL URLWithString:imageURLString];
[myImageView sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
}
Also make sure that you use the latest version of SDWebImage.
Some issues arise when using SDWebImage
with iOS8
alongside with the crash, even when upgrading to the latest 3.7.1 version. A quick fix I found is to add the libPods-SDWebImage.a
to the list of the linked binaries of the project (Select your project target > Build Phases > Link Binary With Libraries > click the '+' and add libPods-SDWebImage.a
).
This is a fix for cocoapods users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With