Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8975179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:48:47+00:00 2026-06-15T18:48:47+00:00

I have a uitableview and each cells have an image from facebook image profile

  • 0

I have a uitableview and each cells have an image from facebook image profile and 2 uilabels (from singleton, not an internet request)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
    static NSString *CellIdentifier = @"MenuCell";
    MenuCellViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    if (cell == nil) {
        cell = [[MenuCellViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    //Singleton
    DataModel *m = [DataModel getModel];
    switch ([indexPath section]) {
        case 0: //Only Header
            break;

        case 1: //My cells
        {
            //If footer - set footer background
            if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section] - 1){
               [cell setBackgroundView:[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"imgFooter.png"]]];
            //Else - set normal cell background
            } else {
                [cell setBackgroundView:[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"img.png"]]];
            }

            //Get Facebook image
            strForImg = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture?type=square",[[[m list] objectAtIndex:indexPath.row] objectForKey:@"id"]];    
            url =[NSURL URLWithString:strForImg];
            img = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
            [cell.imgProfile setImage:img];

            //Set some text (uilabels)
            cell.lblNom.text = [[[m list] objectAtIndex:indexPath.row] objectForKey:@"name"];
            cell.lblTour.text = [[[m list] objectAtIndex:indexPath.row] objectForKey:@"description"];
            break;
        }
    }
}

This code is very slow and freezes the tableview as it loads from facebook the profile images of each cell dynamically.

I tried doing with a dispatch like this

case 1://My cells
    {
        if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section] - 1){
           [cell setBackgroundView:[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"imgFooter.png"]]];
        } else {
            [cell setBackgroundView:[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"img.png"]]];
        }

        dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
        dispatch_async(queue, ^{
            dispatch_sync(dispatch_get_main_queue(), ^{
                strForImg = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture?type=square",[[list objectAtIndex:indexPath.row] objectForKey:@"id"]];

                url =[NSURL URLWithString:strForImg];
                img = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
                [cell.imgProfile setImage:img];

            });
        });
        cell.lblNom.text = [[[m list] objectAtIndex:indexPath.row] objectForKey:@"name"];
        cell.lblTour.text = [[[m list] objectAtIndex:indexPath.row] objectForKey:@"description"];
        break;
    }

The speed has slighty increased but it is still FREEZING when scrolling.

Is my dispatch not correct ? (I have just discovered it, maybe it is not well used).

Or is there any better method ?
I like the facebook friend picker. It puts a default profile image and refreshes the correct image profile when it is received from internet. How is this magic done ? 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:48:49+00:00Added an answer on June 15, 2026 at 6:48 pm

    Fix this block:

     dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
            dispatch_async(queue, ^{
                    strForImg = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture?type=square",[[list objectAtIndex:indexPath.row] objectForKey:@"id"]];
    
                    url =[NSURL URLWithString:strForImg];
                    img = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
                dispatch_sync(dispatch_get_main_queue(), ^{
                    [cell.imgProfile setImage:img];
    
                });
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a UITableView and i am showing different images in cells,each image has
I have a UITableView with two custom cells and each of them has a
I have a UITableView with 15 cells, each with a separate text box in
I have around 20 tableview cells that each contain a number (2-5) thumbnail sized
I have a UITableView subclass and a UITableViewCell subclass that I'm using for cells.
I have a UITableView with a title and an image on each cell. Some
I have a UITableView consisting of roughly 10 subclassed UITableViewCell s named TBPostSnapCell. Each
I have a UITableView with a set of UITableViewCell s in it - each
I have data and image in cells of UITableView. I want to change image
I have the following code - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.