2011-10-25 24 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 ... –