UIImage in uitableViewcell slowdowns scrolling table

后端 未结 3 1954
说谎
说谎 2020-12-22 06:59

Hello I am trying to get profile image of facebook user in Table\'s cell.image. But It slows down Scrolling of Table view.Then I used Asynchronous loading of image link But

相关标签:
3条回答
  • 2020-12-22 07:41
        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;
    

    This code is creating the described problem ..... try this approch ... once any image is downloaded save it in any temp folder in document directory(make name of ur image such that you can identify each of them uniquely)....and when you have to configure the cell just take the image form tha temp folder every time the method celForRowAtIndexPath is called .... dont use

       UIImageView *image_view = [[UIImageView alloc];
    

    This make no sence here as you are not using it (you are just using its .image property) .... also if possible collect all you data in viewDidLoad in that way you can further improve the performance

    0 讨论(0)
  • 2020-12-22 07:43

    Its slows down because you are setting the image every time the cellForRowAtIndexPath: is called. Add the image to the cell's imageView only inside the if (cell == nil) block. Then you will see the improvement in scrolling.

    0 讨论(0)
  • 2020-12-22 07:49

    Are you sure it's the async image causing problems? Comment the async image part, and see maybe it's the FbGraphResponse part the actual cause.

    I see that you're creating an image each time for the graph response and this can cause a slow-down.

    0 讨论(0)
提交回复
热议问题