我正在使用 SDWebView 图像,我想将活动指示器显示为占位符,同时从远程获取图像。
我在这里尝试了 Malek 的回答How to show an activity indicator in SDWebImage,但似乎
UIImage *cachedImage = [manager imageWithURL:url];
已弃用。
有没有人使用这个库可以告诉我如何在加载图像时插入活动指示器?
编辑
按照迈克尔弗雷德里克的指示,我最终得到了这段代码,一切正常。
UIActivityIndicatorView *activityIndicator = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] autorelease];
activityIndicator.hidesWhenStopped = YES;
activityIndicator.hidden = NO;
[activityIndicator startAnimating];
activityIndicator.center = CGPointMake(self.tipImage.frame.size.width /2, self.tipImage.frame.size.height/2);
[imageView setImageWithURL:[NSURL URLWithString:imageString]
placeholderImage:nil options:SDWebImageProgressiveDownload
success:^(UIImage *image) { [activityIndicator stopAnimating];[activityIndicator removeFromSuperview]; }
failure:^(NSError *error) { [activityIndicator stopAnimating];[activityIndicator removeFromSuperview]; }];
[imageView addSubview:activityIndicator];