1

ここでは、FacebookAPIを使用してiPhoneアプリを作成しています。友達リストとそのプロフィール写真をテーブルビューにロードしました。しかし、今ではゆっくりと実行されています。写真の読み込みを高速化したいのですが、どうすればよいですか?

これが私のサンプルコードです:

- (void)request:(FBRequest*)request didLoad:(id)result { 
    NSArray* users = result; 
    for (int ndx = 0; ndx < [users count] ; ndx++)
    {
        NSDictionary* user = [users objectAtIndex:ndx]; 
        NSString* name = [user objectForKey:@"name"];
        NSString *imageName = [user objectForKey:@"pic_big"];
        [imageArray addObject:imageName];
        [friendsList addObject:name];
    }
}

テーブルビューデリゲートメソッドの場合:

imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString: [imageArray objectAtIndex:indexPath.row]]];
        image = [[UIImage alloc] initWithData:imageData];

        cell.imageView.image =image;

また、画像のサイズも異なります。助けてください

4

1 に答える 1

1

Lazyloading の概念を使用すると、高速に実行できます。遅延読み込み用にこのクラスを
ダウンロードするだけです。

妨害するのは非常に簡単です。

 #import "UIImageView+WebCache.h"  // Import this

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
     ------------------ 
     ------------------
[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]  placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

    cell.textLabel.text = @"My Text";
    return cell;
}
于 2011-10-20T08:28:25.803 に答える