i am showing around 100 of the urls in my one screen asyncronusly in my button image with the SDWebImage.
i am facing issues with the memory load when i tried to show all the images from the url.
i have one UIScrollView and In that i have one UIImageView which has all the 100 Uibutton Added Dynamaically.
Now my requirement is when user Zoomed int he UIScrollView at certain Level i need to show image in UIbutton and when i start to show the Image from the server to that button with the following code its crashes witht he memory warning.
[btn sd_setImageWithURL:[NSURL URLWithString:busOwner.WhiteLargeLogoURL] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:placeHolderImage]];
can any one please let me know that how can i resolve this memory issues and can also show the images at same time to all the 100 buttons?
i have also tried to put uiiamgeView instead of uiButton and also i have tried to use
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);
dispatch_async(queue, ^{
// Perform non main thread operation
for (BusinessOwnerEntity *busOwner in arrBusOwner) {
NSURL *url = [NSURL URLWithString:busOwner.WhiteLargeLogoURL];
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadImageWithURL:url options:SDWebImageProgressiveDownload progress:^(NSInteger receivedSize, NSInteger expectedSize) {
NSLog(@"REcieved File %ld",(long)receivedSize);
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
}];
}
dispatch_sync(dispatch_get_main_queue(), ^{
// perform main thread operation
});
});
to download images before but its crashes here too..
Use
SDWebImagecallbacks to load your images in queue, not all at the same time.It will reduce your memory consumption and avoid iOS to kill your app.