FBProfilePictureView in a uitableview recreates it self each time

בועז יערי

I have a UITableView that holds an FBProfilePictureView and a UILable,

my problem is when a user scrolls the picture rebuilds its self and it takes time to show the image it self, i want to know how can i create the FBProfilePictureView once and then when the user scrolls it won't build it self again.

Here is my code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    Messages *msg = [messages objectAtIndex:indexPath.row];
    NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
    NSData *encodedDataObject = [def objectForKey:@"myUser"];
    User *user = (User *)[NSKeyedUnarchiver unarchiveObjectWithData: encodedDataObject];

    if(![msg.wrote_id isEqualToString:user.fid])
    {
        NSString *idToImage = [self getOtherUserId];
        NSString *CellIdentifier = @"Cell";
        ChatWindowCell *cell = nil;
        cell = (ChatWindowCell *)[tableChat dequeueReusableCellWithIdentifier:CellIdentifier];

        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ChatWindowCell" owner:nil options:nil];
        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[ChatWindowCell class]])
            {
                cell = (ChatWindowCell *) currentObject;
                cell.profile_image.profileID=nil;
                if(cell.profile_image.profileID.length>0)
                {

                    return cell;
                }
                break;
            }
        }
        cell.profile_image.profileID = idToImage;
        NSString *text = msg.msg;
        cell.lblMessage.text=text;
        return cell;
    }
    else
    {
        NSString *CellIdentifier = @"Cell";
        ChatCellMe *cell = nil;
        cell = (ChatCellMe *)[tableChat dequeueReusableCellWithIdentifier:CellIdentifier];
        //  if (cell == nil) {

        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ChatCellMe" owner:nil options:nil];
        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[ChatCellMe class]])
            {
                cell = (ChatCellMe *) currentObject;
                NSLog(cell.prof_img.profileID);
                cell.prof_img.profileID=nil;

                if(cell.prof_img.profileID.length>0)
                {
                    return cell;
                }
                break;
            }
        }

        cell.prof_img.profileID = user.fid;
        NSString *text = msg.msg;
        cell.lblText.text=text;
        isMessageFromMe=false;
        return cell;

    }



}

any help would be great guys...

thanks a lot.

combinatorial

I created an alternate view to solve this problem, see https://github.com/combinatorial/DBFBProfilePictureView

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

UITableView with UIWebView in each cell

From Dev

Why is my window loaded each time I access `self.window`

From Dev

how can i store self.astring without clearing the data each time of the recursion?

From Dev

how to hide FBProfilepictureview

From Dev

Turn FBProfilePictureView into UIImage

From Dev

Self Sizing Cells make UITableView jump

From Dev

Self sizing UITableView cell not sizing correctly

From Dev

Activity Recreates and blinking

From Dev

Android on finish() recreates Activity

From Dev

Fragment recreates twice

From Dev

FBProfilePictureView not filling the assigned space in the storyboard

From Dev

Having a hard time reloading UITableView

From Dev

Visual VM: how to interpret Self Time vs Self Time (CPU)

From Dev

getting data from each UITableView Cells Swift

From Dev

Use different custom cell for each section in UITableView

From Dev

Adding specific data for each section in UITableView - Swift

From Dev

UITableView unwanted white line on each line separator

From Dev

Push different UIView for each row of UITableView

From Dev

Select one row in each section of UITableView ios?

From Dev

UITableView unwanted white line on each line separator

From Dev

Select one row in each section of UITableView ios?

From Dev

UITableView Sections. For each cell - a section with the title

From Dev

Creating Sections That Are Independent Of Each Other in UITableView

From Dev

UITableView with NSFetchedResultsController: Sort each section independently of each other

From Dev

Is it posible for UITableView to include some self sized cells and custom height cells?

From Dev

AJAX recreates accordions and breaks them

From Dev

AJAX recreates accordions and breaks them

From Dev

UITableView requires double tap - but not first time

From Dev

How to prevent clicking UITableView second time

Related Related

  1. 1

    UITableView with UIWebView in each cell

  2. 2

    Why is my window loaded each time I access `self.window`

  3. 3

    how can i store self.astring without clearing the data each time of the recursion?

  4. 4

    how to hide FBProfilepictureview

  5. 5

    Turn FBProfilePictureView into UIImage

  6. 6

    Self Sizing Cells make UITableView jump

  7. 7

    Self sizing UITableView cell not sizing correctly

  8. 8

    Activity Recreates and blinking

  9. 9

    Android on finish() recreates Activity

  10. 10

    Fragment recreates twice

  11. 11

    FBProfilePictureView not filling the assigned space in the storyboard

  12. 12

    Having a hard time reloading UITableView

  13. 13

    Visual VM: how to interpret Self Time vs Self Time (CPU)

  14. 14

    getting data from each UITableView Cells Swift

  15. 15

    Use different custom cell for each section in UITableView

  16. 16

    Adding specific data for each section in UITableView - Swift

  17. 17

    UITableView unwanted white line on each line separator

  18. 18

    Push different UIView for each row of UITableView

  19. 19

    Select one row in each section of UITableView ios?

  20. 20

    UITableView unwanted white line on each line separator

  21. 21

    Select one row in each section of UITableView ios?

  22. 22

    UITableView Sections. For each cell - a section with the title

  23. 23

    Creating Sections That Are Independent Of Each Other in UITableView

  24. 24

    UITableView with NSFetchedResultsController: Sort each section independently of each other

  25. 25

    Is it posible for UITableView to include some self sized cells and custom height cells?

  26. 26

    AJAX recreates accordions and breaks them

  27. 27

    AJAX recreates accordions and breaks them

  28. 28

    UITableView requires double tap - but not first time

  29. 29

    How to prevent clicking UITableView second time

HotTag

Archive