Open serkanb opened 10 years ago
photo.imageView.image
is holding a placeholder image until it downloads the real image from the server, which causes the placeholder to be displayed in the photo gallery instead of the real photo.
I don't know much about SDWebImage, but does it have some kind of way of notifying that it has finished downloading the image from the server?
If not, I'd recommend finding another way of downloading images from the server or modifying SDWebImage. Right now there's no support for refreshing photos in the gallery once you've passed in an image to display.
Thanks Eddy, I used SDWebImages below method like you said.
[self.manager cachedImageExistsForURL:photo.url completion:^(BOOL isInCache) { ... }
How can I show activity indicator until image is became ready?
There used to be built in support for an activity indicator animating while waiting for content to appear, but due to a bug it's not working.
Not a very useful answer, but I just haven't had time to fix it with all my other work going on.
On Monday, July 21, 2014, serkanb notifications@github.com wrote:
Thanks Eddy, I used SDWebImages below method like you said.
[self.manager cachedImageExistsForURL:photo.url completion:^(BOOL isInCache) { ... }
How can I show activity indicator until image is became ready?
— Reply to this email directly or view it on GitHub https://github.com/EddyBorja/EBPhotoPages/issues/9#issuecomment-49659255 .
Activity indicator started to run after I had made below changes in EBPhotoViewController and EBImageLoadOperation
in EBPhotoViewController I've made below chances:
#pragma mark - (Operations)
@implementation EBPhotoViewController (Operations)
- (void)operationWillStartLoading:(NSOperation *)operation
{
NSAssert(self.activeOperations, @"Must have a pendingOperations set.");
// I've added below if check
if ([operation isKindOfClass:[EBImageLoadOperation class]]) {
[self.activeOperations addObject:operation];
[self showActivityIndicator];
}
}
- (void)operationDidStopLoading:(NSOperation *)operation
{
NSAssert(self.activeOperations, @"Must have a pendingOperations set.");
// I've removed below assert
// NSAssert([self.activeOperations containsObject:operation], @"PendingOperations did not contain given operation.");
[self.activeOperations removeObject:operation];
// I've removed below if
// if(self.activeOperations.count == 0){
//I've added below if check
if ([operation isKindOfClass:[EBImageLoadOperation class]]) {
[self hideActivityIndicator];
}
//}
}
in EBImageLoadOperation I've made below changes
@implementation EBImageLoadOperation
@implementation EBPhotoPagesOperation
- (void)main
{
@autoreleasepool {
NSAssert(self.photoPagesController, @"Must have a photo pages controller assigned.");
NSAssert(self.photoViewController, @"Must have a photo view controller to pass image to");
NSAssert(self.dataSource,@"Must have a datasource to retrieve image from");
[self setLoadingFinished:NO];
[self operationWillStart];
[self loadData];
// I've removed below line.
// [self operationDidFinish];
}
}
#pragma mark - Image Loading
@implementation EBImageLoadOperation
- (void)loadData
{
if([self.dataSource respondsToSelector:@selector(photoPagesController:imageAtIndex:)]){
[self performSelectorOnMainThread:@selector(loadImageOnMainThread)
withObject:nil
waitUntilDone:NO];
} else if ([self.dataSource respondsToSelector:
@selector(photoPagesController:imageAtIndex:completionHandler:)]){
[self.dataSource photoPagesController:self.photoPagesController
imageAtIndex:self.photoViewController.photoIndex
completionHandler:^(UIImage *image){
[self.photoViewController performSelectorOnMainThread:@selector(setImage:)
withObject:image
waitUntilDone:YES];
// I've added below line
[self operationDidFinish];
}];
}
}
Hello, First of all thanks for wonderful control. I have a problem with refreshing images. My app download images from web server with SDWebImage. It shows a placeholder image until the real one is received. The image is embedded in imageAtIndex method. The problem is the real image is not replaced with placeholder image.
How can I refresh the image? Could you help me please?