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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:57:24+00:00 2026-05-24T15:57:24+00:00

I can not set the custom cells accessory view while the page loads for

  • 0

I can not set the custom cells accessory view while the page loads for the first time, any ideas?

In DetailView customcell’s class I have this:

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    if(self.selected)
       self.accessoryType=UITableViewCellAccessoryCheckmark;
    else
       self.accessoryType=UITableViewCellAccessoryNone;
}

And In tableview controller:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    

      DetailViewCell *cell = [DetailViewCell  cellForTableView:tableView];

      if(somelogichere){            
        [cell setSelected:YES];
      }
        return cell;
}

I debug and hit that line so logic is true, but in debug I also see that after it sets the accesory then again it calls twice the selected method, which overrrides the accessory to none in the else inthe second call. setSelected causes the selected method to be called twice and overrides the setting on the second call cause somehow on second call self.selected returns false;

UPDATE: I solved the problem by creating a boolean cellSelected property in the custom cell class and changing and checking its status rather than setting and changing the selected property of the cell, this is also better cause I can support multi selection tableview’s better in future.

  • 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-24T15:57:25+00:00Added an answer on May 24, 2026 at 3:57 pm

    Does it work the second time after the view has loaded?

    It most probably has something to do with following line:

      if(somelogichere){            
        [cell setSelected:YES];
      }
    

    What is somelogichere ?

    Depending on somelogichere your selected property might not be true the first time you run your code:

    if(self.selected)
       self.accessoryType=UITableViewCellAccessoryCheckmark;
    else
       self.accessoryType=UITableViewCellAccessoryNone;
    

    Make sure you set your cell’s selected property in the beginning. Or change the code inside your setSelected.

    HTH

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

Sidebar

Related Questions

How can i read cookie set date? In rails api I can not find
How can I set label's border which is dynamically generated (Not from Interface Builder)?
Is there a way I can set a ShowDialog() to not be topmost? I've
I am not able to find a way to set TransactionIsolation in ejb. Can
I have several parts in my app where I use custom table view cells.
First question ever on stackoverflow. Been reading for some time now, while trying to
How can I validate the cells in a DataGridColumn individually? (ActionScript 3.5) The validation
I need to set custom attributes on a control as it is bound to
In my method to set labels in my cells (for an UITableView) I'm reading
For a long time I've been trying different languages to find the feature-set I

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.