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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:32:12+00:00 2026-06-17T11:32:12+00:00

I have a table view that needs a custom UITableViewCellAccessoryCheckmark. The checkmark displays when

  • 0

I have a table view that needs a custom UITableViewCellAccessoryCheckmark. The checkmark displays when a row is selected and disappears when anther row is selected and then appears on the last most selected view. That works fine.

the problem arises when I use this line:

 cell.accessoryView = [[ UIImageView alloc ]
                            initWithImage:[UIImage imageNamed:@"icon-tick.png" ]];

to add a custom UITableViewCellAccessoryCheckmark. After that code the UITableViewCellAccessoryCheckmark remain on all rows and don’t disappear when another row is touched.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

int index = indexPath.row; id obj = [listOfItems objectAtIndex:index];

   UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];

NSLog(@"%d",indexPath.row);
if (rowNO!=indexPath.row) {
    rowNO=indexPath.row;
    [self.tableView cellForRowAtIndexPath:indexPath].accessoryType=UITableViewCellAccessoryCheckmark;

    cell.accessoryView = [[ UIImageView alloc ]
                            initWithImage:[UIImage imageNamed:@"icon-tick.png" ]];

    [self.tableView cellForRowAtIndexPath:lastIndexPth].accessoryType=UITableViewCellAccessoryNone;
    lastIndexPth=indexPath;
}
  • 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-17T11:32:13+00:00Added an answer on June 17, 2026 at 11:32 am

    A much cleaner and cooler way would be to overwrite UITableViewCell like this:

    - (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType
    {
        // Check for the checkmark
        if (accessoryType == UITableViewCellAccessoryCheckmark)
        {
            // Add the image
            self.accessoryView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"YourImage.png"]] autorelease];
        }
        // We don't have to modify the accessory
        else
        {
            [super setAccessoryType:accessoryType];
        }
    }
    

    If you have done that, you can continue using UITableViewCellAccessoryCheckmark because your class will automatically replace it with an image.

    You should only set the style in your cellForRowAtIndexPath method. Like this:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // [init subclassed cell here, dont forget to use the table view cache...]
    
        cell.accessoryType = (rowNO != indexPath.row ? nil : UITableViewCellAccessoryCheckmark);
    
        return cell;
    }
    

    And then, you just have to update rowNO in didSelectRowAtIndexPath to update your data and redraw the cell, like this:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    
        if (rowNO != indexPath.row)
        {
            rowNO = indexPath.row;
        }
    
        [self.tableView reloadData]; 
    
    }
    

    Also, instead of reloading the whole table with [self.tableView reloadData], you could only reload the two cells that change their style (e.g. checkmark) using reloadRowsAtIndexPaths.

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

Sidebar

Related Questions

I have a table view that displays custom cells, the cells contain an image
I have some custom table view cells that takes a while to draw, so
I have a table view that displays a list that I want the user
I have a table view that I am customizing and I am adding a
I have a table view that is managed by an NSFetchedResultsController. I am having
I have one table view that should be filtered by values of search field
I have a table view controller with (among others) a cell that is to
I have a first table view and a segue that pushes to another table
I have an app that presents Table View of different files. I have it
I have an MVC application view that is generating quite a large HTML table

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.