2011-10-25 14 views

回答

2

您正在尝试异步图像。有一个在提供一个伟大的文章:http://www.markj.net/iphone-asynchronous-table-image/

内connectionDidFInishLoading只是把在此之后

UIImageView* imageView = [[[UIImageView alloc] initWithImage:[UIImage imageWithData:data]] autorelease]; 
//Paste below code here 

后褪色它:

//Paste following here 
imageView.alpha = 0.0f; 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.5f]; 

imageView.alpha = 1.0f; 

[UIView commitAnimations]; 
+0

谢谢,但我需要淡入效果。 –

+0

评论已经更新。 –

+0

谢谢哥们:) – Abo3atef

5

SDImageWeb是一个相当不错的库,它做什么你需要。它甚至具有图像缓存,所以一旦下载图像,下次从本地闪存中选取它们。

这是什么不能做的是fadeIn效果。但这很容易添加,动画为UIView

所以异步下载图像, [imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]];

多数民众赞成..

要淡入动画放。

- (void)fadeInLayer:(CALayer *)l 
{ 
    CABasicAnimation *fadeInAnimate = [CABasicAnimation animationWithKeyPath:@"opacity"]; 
    fadeInAnimate.duration   = 0.5; 
    fadeInAnimate.repeatCount   = 1; 
    fadeInAnimate.autoreverses  = NO; 
    fadeInAnimate.fromValue   = [NSNumber numberWithFloat:0.0]; 
    fadeInAnimate.toValue    = [NSNumber numberWithFloat:1.0]; 
    fadeInAnimate.removedOnCompletion = YES; 
    [l addAnimation:fadeInAnimate forKey:@"animateOpacity"]; 
    return; 
} 

要调用这个 - [self fadeInLayer: imageView.layer];

这应该做的伎俩。这动画,您的图像在0.5秒内从alpha 0到1!在动画中给予美妙的淡入淡出。

+0

谢谢老兄。你能说我如何以编程方式添加fadeIn效果吗?当用户滚动并查看其他UIImageViews时,我会使用淡入效果来显示图像。 –

+0

查看我的更新代码fadein animaiton ... –