使用SDWebImageDownloader显示和隐藏ActivityIndi​​cator

时间:2013-03-01 07:38:17

标签: iphone ios uiactivityindicatorview sdwebimage

我在视图中按下每个按钮时使用SDWebImageDownloader类加载图像。

__block UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.center = mainImage.center;
activityIndicator.hidesWhenStopped = YES;

[activityIndicator startAnimating];
[imgView setImageWithURL:url   placeholderImage:[UIImage imageNamed:@"placeholderLarge.png"] options:0 andResize:CGSizeMake(mainImage1.frame.size.width,imgview.frame.size.height) withContentMode:UIViewContentModeScaleAspectFit];
[imgView addSubview:activityIndicator];

我无法删除activityIndi​​cator

的位置

1 个答案:

答案 0 :(得分:1)

你可以使用下面的块..它更有效,它对我有用......

[imgView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"Default.png"] success:^(UIImage *image, BOOL cached){
        [activityIndicator stopAnimating];
    } failure:^(NSError *error){  
     //do any additional tasks if its failure
        }];