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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:42:16+00:00 2026-06-01T12:42:16+00:00

i have a custom UITableView Cell, i have selected a particular cell and goes

  • 0

i have a custom UITableView Cell, i have selected a particular cell and goes to another ViewController, when i came back to first view controller, selected state of the cell is not visible. how will i unchanged the selected state of a cell after navigating from another viewControllers?

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   return [timeSet count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   timeSettingCell *newCell = nil;
   newCell = [tableView dequeueReusableCellWithIdentifier:identifier];
   if(newCell == nil)
   {
    NSLog(@"newCell ===================");
    NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@"timeSettingCell"   owner:self options:nil];
    newCell  = [ nibViews lastObject];
    }
    newCell.timeLabel.text=[timeSet objectAtIndex:indexPath.row];

    if (newCell.selected==YES) {
      newCell.highlighted=YES;
      newCell.timeImage.image=[UIImage imageNamed:@"radioSelected.png"];
    }
    else {
      newCell.highlighted=NO;
      newCell.timeImage.image=[UIImage imageNamed:@"radioNotSelected.png"];
    }
return newCell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
value=[[time1 objectAtIndex:indexPath.row]integerValue];

SettingsViewController *settings=[[SettingsViewController alloc]initWithNibName:nil bundle:nil andCounterValue:value];
[[self presentingViewController] dismissModalViewControllerAnimated:YES];
index=indexPath.row;
[settings release];
}
-(void)viewWillAppear:(BOOL)animated{
}

thank you

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

    I think you should memorize your cell state (selected or not) using a NSArray created as a singleton, ivar or NSUserDefault and then read its state in cellForRowAtIndexPath.

    EDIT: Sample code

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    // Do what you want
    
    // This save the index of your selected cell on disk
    [[NSUserDefaults standardUserDefaults] setInteger:indexPath.row forKey:@"selectedCell"];
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    // Create your cell
    
    // Here you check if the cell should be selected or not
    if (indexPath.row == [[NSUserDefaults standardUserDefaults] integerForKey:@"selectedCell"]) {
        newCell.highlighted=YES;
        newCell.timeImage.image=[UIImage imageNamed:@"radioSelected.png"];
    } else {
        newCell.highlighted=NO;
        newCell.timeImage.image=[UIImage imageNamed:@"radioNotSelected.png"];
    }
    
    return aCell;
    }
    

    NSUserDefaults is useful to save data on your device and retrieve them later. This mean you can check your cell status even after closing and reopening your app.

    To use NSUserDefaults you need to add a Settings.bundle to you project. Take a look at NSUserDefaults Class Reference

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

Sidebar

Related Questions

I have a custom UITableView cell that has a UIImageView sized to the width
I have a UITableView, and custom cells on it. On cell I have a
I have a custom UITableView cell which has a button and a label. I
i have a UITableView , within each cell i have 2 custom buttons, what
I have built a custom UITableView with two cells. In one cell I have
I have custom table view cell with images (loaded from app document directory), labels,
I have a UITableView with custom cell. I have created seperate class with xib
I have a custom uitableview with a UILabel to the right of the cell
i want to push a view controller for each cell selected, to show different
I have a custom UITableView cell that sports an Image, and a headline. 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.