在UIImageView图像加载完成后停止动画UIActivityIndi​​catorView

时间:2012-04-04 11:59:01

标签: objective-c ios uiimageview

我想在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];
}

然而,这不起作用,因为活动视图不断旋转。

2 个答案:

答案 0 :(得分:1)

旋转器始终是动画的,因为

- (void)viewWillAppear:(BOOL)animated;

之后调用

- (void)viewDidLoad

所以基本上你告诉微调器在告诉它停止后动画。

祝你好运!

答案 1 :(得分:1)

氦气是对的。您希望在结果块内将cal移动到[_ImageLoader stopAnimating],或者最终在动画开始之前停止动画。

相关问题