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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:17:41+00:00 2026-06-17T12:17:41+00:00

The code below works when I want to highlight and put a check mark

  • 0
  1. The code below works when I want to highlight and put a check mark next to the selected cell.

  2. It also works when I want to select another cell as it deselects the last cell or highlight and puts a check mark and highlight next to the new selected cell.

  3. It also work when I reselect a selected cell as it deselects it leaving no check mark and highlight in the UITable.

  4. However, when I select the the same cell for the third time (meaning, I first selected it, the code highlighted it and put a checkmark next it. I selected the same cell the 2nd time, and it removed the highlight and the checkmark, it is now the third time I’m selecting the same cell) it highlights the cell for a fraction of a second and than the highlight disappears. The checkmark next to the cell also never shows up as if I had just deselected it. No matter how many times I select the same cell, it does not highlight it or put a check mark next to it. The only way to accomplish this is to select another cell first, and then reselect the original cell. Please help.

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
    {
    
        // select new
    
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
    
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
        [cell setSelected:TRUE animated:TRUE];
    
        // deselect old
        UITableViewCell *old = [self.tableView cellForRowAtIndexPath:self.lastSelected];
    
        old.accessoryType = UITableViewCellAccessoryNone;
        [old setSelected:FALSE animated:TRUE];
    
    
        // keep track of the last selected cell      
        self.lastSelected = indexPath;
    
    }
    

I built the UITableView via Storyboard.

  • 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-17T12:17:42+00:00Added an answer on June 17, 2026 at 12:17 pm

    Just a small adjustment of the logic there:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
    {
    
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
    
        if (self.lastSelected && (self.lastSelected.row == indexPath.row)) {
            cell.accessoryType = UITableViewCellAccessoryNone;
            [cell setSelected:NO animated:TRUE];
            self.lastSelected = nil;
        } else {
           cell.accessoryType = UITableViewCellAccessoryCheckmark;
           [cell setSelected:TRUE animated:TRUE];
    
            UITableViewCell *old = [self.tableView cellForRowAtIndexPath:self.lastSelected];
            old.accessoryType = UITableViewCellAccessoryNone;
            [old setSelected:NO animated:TRUE];
            self.lastSelected = indexPath;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to put the id into the colorbox below this code nom works
I have the following code below which works, but I want to insert values
See code below: I want Page 1 to alert #testing... This works in C
I'm just looking to optimize the code below. It works, but I want to
The code below works exactly as I want it to in my perl script.
The code below works fine at 1280x800, however, if I add another thumbnail, the
I want to change JDialog icon. Code below works for *.jpg files, but doesn't
I want to make a table of SVG images. The code below works fine
The code below works as I want, switching a light on or off with
The code below does not work but meant to illustrate what I want to

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.