2011-06-20 5 views
0

こんにちは私は、テーブルのcell.imageでfacebookユーザーのプロフィールイメージを取得しようとしています。しかし、あなたはimagecellForRowAtIndexPath:が呼び出されるたびに設定されているので、遅くそれは私がAsynchronous loading of imageリンクを使用し、表view.Thenのスクロールが遅くなります。しかし、私は私の表のメソッドuitableViewcellのUIImageがスクロールテーブルをスローダウン

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

     static NSString *CellIdentifier = @"Cell"; 

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
     if (cell == nil) { 
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 
     } 

     cell.textLabel.font = [ UIFont fontWithName:@"Arial" size:10.0]; 
     cell.textLabel.numberOfLines = 0; 

     cell.textLabel.text = [NSString stringWithFormat:@"%@",[(Facebook *)[dummyArray objectAtIndex:indexPath.row] sender]]; 

     cell.detailTextLabel.text =[NSString stringWithFormat:@"%@",[(Facebook *)[dummyArray objectAtIndex:indexPath.row] post]]; 

     NSString *get_string = [NSString stringWithFormat:@"%@/picture",[(Facebook *)[dummyArray objectAtIndex:indexPath.row]senderId]]; 

     AsynchronousImageView *image = [[AsynchronousImageview alloc]init]; 
[image loadImagewithUrlString:getString]; 

     FbGraphResponse *fb_graph_response = [fbGraph doGraphGet:get_string withGetVars:nil]; 

     UIImageView *image_view = [[UIImageView alloc] initWithImage:fb_graph_response.imageResponse]; 


     cell.imageView.image = image_view.image; 



     [image_view release]; 


     return cell; 
    } 

答えて

4

その中で、これを使用することができますどのように私は混乱しています。画像をセルのimageビューに追加するのは、if (cell == nil)ブロック内のみです。その後、スクロールの改善が見えます。あなたが識別できるように

+3

彼がセルを再利用するとき、彼はイメージをそのインデックスの正しい値にリセットする必要があります。 –

+0

ありがとうございます。今はうまくいきます。この場合、私はこの非同期イメージのロードを使用する必要はありません。 – iProgrammer

+0

@Andrei Stanescu、はい。しかし、それはこの問題の範囲外です。 :-) – EmptyStack

0
AsynchronousImageView *image = [[AsynchronousImageview alloc]init]; 
    [image loadImagewithUrlString:getString]; 

    FbGraphResponse *fb_graph_response = [fbGraph doGraphGet:get_string withGetVars:nil]; 

    UIImageView *image_view = [[UIImageView alloc] initWithImage:fb_graph_response.imageResponse]; 


    cell.imageView.image = image_view.image; 

説明し、問題を作成しているこのコードは.....一度任意の画像は、ドキュメントディレクトリ内の任意の一時フォルダに保存ダウンロードされ、このapprochを...してみてください(ウル画像の名前を作りますそれらの各一意)......と、あなただけの画像形式股関節tempフォルダ法celForRowAtIndexPathが呼び出されるたびに要するセルを設定する必要がある場合...これはここにはローミングサービスをしない

UIImageView *image_view = [[UIImageView alloc]; 

を使用してはいけませんあなたはそれを使用していないので(あなたはちょうどその.imageプロパティを使用しています...)可能であれば、あなたのすべてのデータをviewDidLoadに集めてくださいあなたはさらにパフォーマンスを向上させることができます

0

問題を引き起こすのは非同期イメージですか?非同期の画像部分をコメントしてください。おそらくFbGraphResponseの部分が実際の原因を参照してください。

私は、グラフ応答のたびにイメージを作成していることがわかります。これは、スローダウンを引き起こす可能性があります。

+0

非同期イメージはprobを引き起こしていません。実際は、いつもイメージを作成しているためにテーブルビューのスクロールが遅くなります。画像例。と私はこれを使用する方法を得ていなかった、私はここで質問をしたが、それはサイモンの提案とうまく動作しています – iProgrammer

関連する問題