2
我使用SDWebImage新版本,並呼籲:sdwebImage setImageWithURL:placeholderImage:完成:
self.imgIndicatorView.center=self.img.center;
self.imgIndicatorView.hidden=NO;
[ self.imgIndicatorView startAnimating];
__block UIActivityIndicatorView *indicatorView= self.imgIndicatorView;
NSLog(@"myTopics.img.small=%@",myTopics.img.small);
[self.img setImageWithURL:[NSURL URLWithString:@"http://ww1.sinaimg.cn/thumbnail/acc940bdj.jpg"]
placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType){
NSLog(@"newImageNotCached:break.png myTopics.img.small");
if(!error){
CGRect sFrame=self.img.frame;
CGSize newSize=image.size;
if (newSize.height>80) {
if (newSize.width>newSize.height) {
newSize.height=newSize.height *80.0/image.size.width;
newSize.width=80;
}else{
newSize.height=80;
newSize.width=newSize.width*80.0/image.size.height;
}
}else{
if (newSize.width>80) {
newSize.height=newSize.height *80.0/image.size.width;
newSize.width=80;
}else{
}
}
sFrame.size=newSize;
self.img.frame=sFrame;
indicatorView.hidden=YES;
[indicatorView stopAnimating];
[indicatorView removeFromSuperview];
}else{
self.img.image=[UIImage newImageNotCached:@"break.png"];
indicatorView.hidden=YES;
[indicatorView stopAnimating];
[indicatorView removeFromSuperview];
}
}];
但有時日誌的NSLog(@ 「newImageNotCached:break.png myTopics.img.small」),不顯示,如果url(@「http://ww1.sinaimg.cn/thumbnail/acc940bdj.jpg」)是break.so指示器視圖總是存在。爲什麼該方法不能調用該塊完成?