[英]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.