2012-04-04 65 views
0

我想通过UIImageView显示旋转活动视图,并在图像加载完成并显示后停止并隐藏活动视图。图像是从资产库中获取的大型照片。当UIImageView图像加载完成时停止UIActivityIndi​​catorView动画

- (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]; 
} 

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

+0

你在哪里调用[_ImageLoader startAnimating]? – Zalykr 2012-04-04 12:21:01

+0

- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [_ImageLoader startAnimating]; } – jcrowson 2012-04-04 12:21:47

+0

他们有不同的名字...是不是你的问题? – Zalykr 2012-04-04 12:23:08

回答

1

微调器始终动画,因为

- (void)viewWillAppear:(BOOL)animated; 

- (void)viewDidLoad 

后调用所以基本上你说的是微调,告诉它停止后的动画。

祝你好运!

+0

谢谢Heliem,现在看起来很明显! – jcrowson 2012-04-12 21:00:40

1

氦气是正确的。您想要将cal移至结果块中的[_ImageLoader stopAnimating],否则您最终会在动画开始前停止动画。

相关问题