2011-06-23 1 views
0

iPhone開発にはかなり新しいです。私は、Webから動的に画像を読み込むスクロールビューを実装しようとしています。私は次のコードを使用しようとしています。どうすれば画像を動的にスクロールできますか

for (counter = 0; counter < 2; counter++) { 
    RSSEntry *entry = [_allEntries objectAtIndex:counter]; 
    NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: entry.articleUrl]]; 
    UIImage *img = [UIImage imageWithData: imageData]; 
    NSLog(@"%@", entry.articleUrl); 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:img]; 
    [imageData release]; 
    CGRect rect = scrollViewController.frame; 
    imageView.frame = rect; 
    imageView.tag = (counter + 1); // tag our images for later use when we place them in serial fashion 
    [scrollViewController addSubview:imageView]; 
    [imageView release]; 
} 

これらは、私がviewDidLoadにロードする2つのイメージです。ユーザーが第2のイメージにスクロールしたときに次のイメージをロードし、次にユーザーがスクロールしてイメージがロード中であることを表示したい場合は、なにか提案を?

答えて

1

NSURLConnectionを使用してイメージを非同期でダウンロードします。あなたはそれが非同期方法で画像をダウンロードしTCImageView

https://github.com/totocaster/TCImageView

を使用することができます。

また、Three20's TTImageViewもお勧めします。

+0

'TCImageView'が更新され、TCWebImageView'という名前に変更されました:https://github.com/totocaster/TCWebImageView –

関連する問題