0

我想使用AsynchronousImageLoaderActivityIndicator从 URL 下载图像并设置在UITableviewCell. 我使用了sdwebimage我想设置的但是而不是占位符图像,Activity Indicator所以请帮助我。

4

2 回答 2

1

You could do it this way :

Add an indicator to your view, place it at the center of your imageview

    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    [indicator startAnimating];
    [indicator setCenter:self.imageView.center];
    [self.contentView addSubview:indicator];

Remove the indicator from the superview in the block's succes method.

    [_imageView setImageWithURL:[NSURL URLWithString:anURL]
                       success:^(UIImage *image) {
                           [indicator removeFromSuperview];
                       }
                       failure:^(NSError *error) {

                       }];
}

Of course you could make a nice subclass for this

于 2012-11-20T08:58:28.443 回答
0

活动指示器是一个视图,我想您的占位符图像只是一个图像。

如果 sdwebimage 不能让您添加视图而不是占位符图像,那么最好的方法是使用活动指示器的动画图像

于 2012-11-20T08:53:31.817 回答