[英]Stop animating UIActivityIndicatorView when UIImageView image has finished loading
I want to display the spinning activity view over a UIImageView and stop and hide the activity view once the image has finished loading and is displayed.我想在 UIImageView 上显示旋转活动视图,并在图像加载完成并显示后停止并隐藏活动视图。 The image is a large photograph taken from the assets-library.
该图像是从资产库中拍摄的大照片。
- (void)viewDidLoad
{
//set photo
UIImageView *Photo = _photo;
NSURL *url = [[NSURL alloc] initWithString:project.photo];
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
[library assetForURL:url resultBlock:^(ALAsset *asset) {
ALAssetRepresentation *rep = [asset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
if (iref) {
self.photo.image = [UIImage imageWithCGImage:[rep fullScreenImage] scale:[rep scale] orientation:0];
}
} failureBlock:^(NSError *error) {
NSLog(@"Couldn't load asset %@ => %@", error, [error localizedDescription]);
}];
[_ImageLoader stopAnimating];
}
This, however, does not work as the activity view is constantly spinning.但是,这不起作用,因为活动视图一直在旋转。
The spinner is always animated because微调器始终是动画的,因为
- (void)viewWillAppear:(BOOL)animated;
is called after被称为
- (void)viewDidLoad
So basically your telling the spinner to animate after telling it to stop.所以基本上你告诉微调器在告诉它停止后进行动画处理。
Good luck!祝你好运!
Helium is right.氦气是对的。 You want to move the cal to [_ImageLoader stopAnimating] inside the result block, or you end up stopping the animation before it even started.
您想要将校准移动到结果块内的 [_ImageLoader stopAnimating],否则您最终会在 animation 开始之前停止它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.