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 6652973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:12:34+00:00 2026-05-26T01:12:34+00:00

I have an UITableView and when I select a cell I wanna put a

  • 0

I have an UITableView and when I select a cell I wanna put a checkmark on the right of the cell….which is pretty easy.

To this end I did the following:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableViewMieux deselectRowAtIndexPath:indexPath animated:YES];

    UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];

    if (selectedCell.accessoryType == UITableViewCellAccessoryNone)
    {
        UIImageView *checkBox = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox-pressed.png"]] autorelease];
        checkBox.frame = CGRectMake(0, 0, 20, 20);
        selectedCell.accessoryView = checkBox;  
        selectedCell.accessoryType=UITableViewCellAccessoryCheckmark;
    }    
    else  if (selectedCell.accessoryType==UITableViewCellAccessoryCheckmark)     
        {
            UIImageView *checkBox = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]] autorelease];
            checkBox.frame = CGRectMake(0, 0, 20, 20);
            selectedCell.accessoryView = checkBox;
            selectedCell.accessoryType=UITableViewCellAccessoryNone;
        }   
    [tableViewMieux  reloadData];
}

Everything works great except the fact that when I select the first cell this gets checkmarked and the fifth cell gets checkmarked automatically too.
And so on…if I select the second cell this gets checkmarked …and another cell from the bottom of the tableView gets marked too.

So, each time I select and mark a cell and extra cell gets marked.

Question:Why?What is the right way to do it?

EDIT:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableViewMieux dequeueReusableCellWithIdentifier:@"CellRecherchePartenaires"];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"CellRecherchePartenaires"] autorelease];

        cell.backgroundColor = [UIColor clearColor];
        cell.selectionStyle = UITableViewCellSelectionStyleGray;
        cell.backgroundView.opaque = NO;

        cell.textLabel.backgroundColor = [UIColor clearColor];
        cell.textLabel.opaque = NO;
        cell.textLabel.textColor = [UIColor whiteColor];
        cell.textLabel.highlightedTextColor = [UIColor whiteColor];
        cell.textLabel.font = [UIFont boldSystemFontOfSize:15];

        cell.detailTextLabel.backgroundColor = [UIColor clearColor];
        cell.detailTextLabel.opaque = NO;
        cell.detailTextLabel.textColor = [UIColor whiteColor];
        cell.detailTextLabel.highlightedTextColor = [UIColor whiteColor];
        cell.detailTextLabel.font = [UIFont systemFontOfSize:15];

        cell.accessoryView=UITableViewCellAccessoryNone;

    }

    // Set up the cell...
    [[cell textLabel] setText: [tableArray objectAtIndex:indexPath.row]] ;

    return cell;
}
  • 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-05-26T01:12:35+00:00Added an answer on May 26, 2026 at 1:12 am
       - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
         {
        NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%d%d", indexPath.section, indexPath.row];
         UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    
        cell.backgroundColor = [UIColor clearColor];
        cell.selectionStyle = UITableViewCellSelectionStyleGray;
        cell.backgroundView.opaque = NO;
    
        cell.textLabel.backgroundColor = [UIColor clearColor];
        cell.textLabel.opaque = NO;
        cell.textLabel.textColor = [UIColor whiteColor];
        cell.textLabel.highlightedTextColor = [UIColor whiteColor];
        cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
    
        cell.detailTextLabel.backgroundColor = [UIColor clearColor];
        cell.detailTextLabel.opaque = NO;
        cell.detailTextLabel.textColor = [UIColor whiteColor];
        cell.detailTextLabel.highlightedTextColor = [UIColor whiteColor];
        cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
    
        cell.accessoryView=UITableViewCellAccessoryNone;
    
    }
    
    // Set up the cell...
    [[cell textLabel] setText: [tableArray objectAtIndex:indexPath.row]] ;
    
    return cell;
    

    }

    Simply try this …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UI which contains a UITableView and a UIDatePicker. When I select
Actually My problem is....suppose i have an UITableView controller when i select a cell
I have a checklist in a UITableView and I have a UISegmentedControl with Select
I have a UITableView cell that is going to have a variable size depending
I have a UITableView which is populated by an array, I have a button
I have a UITableView that displays single large images in each cell. The names
I have a uitableview that loads fairly large images in each cell and the
I have a UITableView with the following code: - (void)viewDidLoad { [super viewDidLoad]; parser
I have one UITableView with a custom cell loaded from a nib file, it
So, I have this UITableView . It's in an iPad application. Some of the

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.