[英]Stop animating UIActivityIndicatorView when UIImageView image has finished loading
我想在 UIImageView 上显示旋转活动视图,并在图像加载完成并显示后停止并隐藏活动视图。 该图像是从资产库中拍摄的大照片。
- (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];
}
但是,这不起作用,因为活动视图一直在旋转。
微调器始终是动画的,因为
- (void)viewWillAppear:(BOOL)animated;
被称为
- (void)viewDidLoad
所以基本上你告诉微调器在告诉它停止后进行动画处理。
祝你好运!
氦气是对的。 您想要将校准移动到结果块内的 [_ImageLoader stopAnimating],否则您最终会在 animation 开始之前停止它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.