I am lazy loading an image via setImageWithURL into a UIImageView embedded in a UIScrollView.
Since this is fora photo gallery, I am trying to use the ‘success’ code block to set myScrollView‘s contentSize and the imageview’s frame after it completely loads so it can zoom properly.
Problem is, I keep getting a strange error using ‘success’ in my call. If I comment out the success/failure portion of the method, it works but I can’t tell when the image finishes loading, and thus cannot size the container correctly so it zooms properly… help?
Error:
Incompatible block pointer types sending
'void (^)(UIImage *__strong)'to parameter of type'SDWebImageSuccessBlock'(aka'void (^)(UIImage *__strong, BOOL)')
Is the error I receive on the following code @ the line beginning with success:^…
Code:
[_ivFullSize setImageWithURL:[NSURL URLWithString:[currentPhoto PhotoAbsoluteLocation]]
placeholderImage:[UIImage imageNamed:@"loading.png"]
success:^(UIImage *image){
[DejalBezelActivityView removeViewAnimated:YES];
self.myScrollView.contentSize = self.ivFullSize.image.size;
self.ivFullSize.frame = CGRectMake(0, 0, self.ivFullSize.image.size.width, self.ivFullSize.image.size.height);
}
failure:^(NSError *error){
[DejalBezelActivityView removeViewAnimated:YES];
}];
I have run into the same problem recently, after upgrading the SDWebImage version to the latest one. I have no idea why this is happening, but I would assume that it is an undocumented change in the function block. Basically the function is returning an additional boolean parameter.
So without knowing the reason of the problem, I have solved it by simply adding a new boolean parameter to the block. Instead of writing
I used the following:
This removes the raised error but still leaves questions on the nature of the additional boolean variable. Any additional documentation or clarification would be greatly appreciated. The documentation here still refers to the old version.