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

  • SEARCH
  • Home
  • 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 8582865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:24:07+00:00 2026-06-11T21:24:07+00:00

My UITableView cells take content (images) from others cells. I have no idea why

  • 0

My UITableView cells take content (images) from others cells. I have no idea why that happening, but I am sure that my mistake is silly. At the image below you can see how it looks. Cells on the top take images from the cells on the bottom (facebook and twitter icons).

Here is my code for cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

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

    NSDictionary *dictionary = [mainArray objectAtIndex:indexPath.section];
    NSArray *array1 = [dictionary objectForKey:@"stuff"];

    NSString *cellValue = [array1 objectAtIndex:indexPath.row];
    cell.textLabel.text = cellValue; // загаловок клетки
    cell.textLabel.font = [UIFont fontWithName:@"TrebuchetMS-Bold" size:16]; 
    cell.textLabel.textColor = [UIColor colorWithRed:145/256.0 green:0/256.0 blue:0/256.0 alpha:1.0];    
    cell.backgroundColor = [UIColor whiteColor];
    cell.selectionStyle = UITableViewCellSelectionStyleGray;
    cell.textLabel.textAlignment = UITextAlignmentLeft;

    if (indexPath.section == 0 && indexPath.row == 1)
    {
        if([[NSUserDefaults standardUserDefaults]boolForKey:@"password"] == YES)
        {
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
    }

    switch(indexPath.section)
    {

        case 2:
        {
            cell.textLabel.textAlignment = UITextAlignmentCenter;
        }
        break;

        case 3:
        {
            if (indexPath.row == 0) 
                cell.imageView.image = [UIImage imageNamed:@"facebook"];
            else if (indexPath.row == 1)
                cell.imageView.image = [UIImage imageNamed:@"twitter"];
            else if (indexPath.row == 2)
                cell.imageView.image = [UIImage imageNamed:@"youtube"];
            else
                cell.imageView.image = [UIImage imageNamed:@"vk"];
        }
        break;
            default:
            break;
    }




    return cell;
}

enter image description here

How can I fix it ?

  • 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-11T21:24:08+00:00Added an answer on June 11, 2026 at 9:24 pm

    Cells are reused, so you have to set the imageView of your cells to nil whenever you don’t want an image to appear. Try this:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
    
        NSDictionary *dictionary = [mainArray objectAtIndex:indexPath.section];
        NSArray *array1 = [dictionary objectForKey:@"stuff"];
    
        NSString *cellValue = [array1 objectAtIndex:indexPath.row];
        cell.textLabel.text = cellValue; // загаловок клетки
        cell.textLabel.font = [UIFont fontWithName:@"TrebuchetMS-Bold" size:16]; 
        cell.textLabel.textColor = [UIColor colorWithRed:145/256.0 green:0/256.0 blue:0/256.0 alpha:1.0];    
        cell.backgroundColor = [UIColor whiteColor];
        cell.selectionStyle = UITableViewCellSelectionStyleGray;
        cell.textLabel.textAlignment = UITextAlignmentLeft;
        cell.imageView.image = nil;
    
        if (indexPath.section == 0 && indexPath.row == 1)
        {
            if([[NSUserDefaults standardUserDefaults]boolForKey:@"password"] == YES)
            {
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
        }
    
        switch(indexPath.section)
        {
    
            case 2:
            {
                cell.textLabel.textAlignment = UITextAlignmentCenter;
            }
            break;
    
            case 3:
            {
                if (indexPath.row == 0) 
                    cell.imageView.image = [UIImage imageNamed:@"facebook"];
                else if (indexPath.row == 1)
                    cell.imageView.image = [UIImage imageNamed:@"twitter"];
                else if (indexPath.row == 2)
                    cell.imageView.image = [UIImage imageNamed:@"youtube"];
                else
                    cell.imageView.image = [UIImage imageNamed:@"vk"];
            }
            break;
            default:
            break;
        }
    
    
    
    
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView whose cells contain custom ImageViews that asynchronously load the images
I have a program where a UITableView contains custom cells loaded from nibs. These
I have a UITableView with cells of different heights and I need to know
I have cells in UITableView , I have made custom frame for the label
I have a UITableView with static cells and I am trying to change the
I have a UITableView with 15 cells, each with a separate text box in
So I have the following: A UITableView with deletable cells (the kind where you
I'm trying to get my UITableView to show cells with images placed on them
In my app I have a set number of cells in a UITableView, 10,
In an app I'm working on, I have a plain style UITableView that can

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.