-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refreshing image #9
Comments
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, [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 Not a very useful answer, but I just haven't had time to fix it with all my On Monday, July 21, 2014, serkanb [email protected] wrote:
|
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?
The text was updated successfully, but these errors were encountered: