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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:06:43+00:00 2026-05-25T20:06:43+00:00

My App consists of 3 views (View 1 (Tableview1), View 2 (Tableview2), View 3

  • 0

My App consists of 3 views (View 1 (Tableview1), View 2 (Tableview2), View 3 (DetailView)).

I have a custom tableview cell set up with subviews (imageViews and Labels) in my View 2 (Tableview2).

One of these subviews is an ImageView, and contains an image if the cell ID is in a favorites Array. When you select a cellForRowAtIndexpath you are pushed to a new view (View 3 (DetailView)), where you can press a button and make the item a favorite.
When you close that view and go back the image is shown, and everything works fine.

My problem occurs when I try to deselect an item as favorite. The favorite symbol is still shown in the tableView, until i go back to View 1 (Tableview1).

I have tried to call [myTableview reloadData], in View 2 on ViewWillAppear, but the favorites symbol is still there. My favorites Array is saved and loaded with the correct values.

The Array gets updated at ViewWillAppear…

What could be the problem?

Relevant code: EDIT – Posted all relevant code from cellForRowAtIndexPath: Everything is showing right, but the tableview does not get updated if I remove an image from the custom cell… EDIT: Updated with else statement in the for loop to try and remove the favorite images from the items that are no longer in the favorites array.
EDIT EDIT EDIT: Working now, added a break statement in my for loop… Updated code so that it might help others…

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

static NSString *CellIdentifier = @"Cell";
CustomCell *cell = (CustomCell *)[myTableView dequeueReusableCellWithIdentifier:CellIdentifier];




if (cell == nil) {
        cell = [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }

[cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

NSString *kategori = [prefs objectForKey:@"kategoriID"];

NSLog(@"KategoriID = %@", kategori);

rowArray = nil;

rowArray = [[NSMutableArray alloc] init];

for(int i=0; i < [listOfItems count]; i++) {

    if([kategori isEqualToString:[listOfItems objectAtIndex:i]])
    {
        //Tilføjer ID
         [rowArray addObject:[NSNumber numberWithInt:i-5]];



    }

}



int arrayValue = [[rowArray objectAtIndex:indexPath.row] intValue];

cell.primaryLabel.text = [listOfItems objectAtIndex:arrayValue+1];
cell.secondaryLabel.text = [listOfItems objectAtIndex:arrayValue+2];
cell.myImageView.image = [UIImage imageNamed:[listOfItems objectAtIndex:arrayValue+4]];


//Time
cell.timeImageView.image = [UIImage imageNamed:@"03-clock.png"];
cell.timeLabel.text = [listOfItems objectAtIndex:arrayValue+6];

//Views
cell.viewsImageView.image = [UIImage imageNamed:@"04-eye.png"];
cell.viewsLabel.text = [listOfItems objectAtIndex:arrayValue+7];


//Stars
NSString *starsString = [listOfItems objectAtIndex:arrayValue+8];


if ([starsString isEqualToString:@"S0"]) {
     cell.starsImageView.image = [UIImage imageNamed:@"0-stars.png"];
}
if ([starsString isEqualToString:@"S0_1"]) {
    cell.starsImageView.image = [UIImage imageNamed:@"0_1-stars.png"];
}
if ([starsString isEqualToString:@"S1"]) {
    cell.starsImageView.image = [UIImage imageNamed:@"1-stars.png"];
}
if ([starsString isEqualToString:@"S1_1"]) {
    cell.starsImageView.image = [UIImage imageNamed:@"1_1-stars.png"];
}
if ([starsString isEqualToString:@"S2"]) {
    cell.starsImageView.image = [UIImage imageNamed:@"2-stars.png"];
}
if ([starsString isEqualToString:@"S2_1"]) {
    cell.starsImageView.image = [UIImage imageNamed:@"2_1-stars.png"];
}
if ([starsString isEqualToString:@"S3"]) {
    cell.starsImageView.image = [UIImage imageNamed:@"3-stars.png"];
}
if ([starsString isEqualToString:@"S3_1"]) {
    cell.starsImageView.image = [UIImage imageNamed:@"3_1-stars.png"];
}
if ([starsString isEqualToString:@"S4"]) {
    cell.starsImageView.image = [UIImage imageNamed:@"4-stars.png"];
}
if ([starsString isEqualToString:@"S4_1"]) {
    cell.starsImageView.image = [UIImage imageNamed:@"4_1-stars.png"];
}
if ([starsString isEqualToString:@"S5"]) {
    cell.starsImageView.image = [UIImage imageNamed:@"5-stars.png"];
}

//favorite
NSString *IDString = [listOfItems objectAtIndex:arrayValue];

NSLog(@"ID String: %@", IDString);

if (videoerIFavoritDatabase == 0) {
    NSLog(@"Der er ingen videoer i favorit databasen!");
}

else {

 for(int i=0; i < [tableviewFavoritArray count]; i++) {

     NSLog(@"ID Array Value:%i", i);

     if([IDString isEqualToString:[tableviewFavoritArray objectAtIndex:i]])
{

    cell.favoriteImageView.image = [UIImage imageNamed:@"favoriteTableview@2x.png"];
    NSLog(@"ER favorit:%i = ID%@", i, [tableviewFavoritArray objectAtIndex:i]);
break;
}
    else { cell.favoriteImageView.image = [UIImage imageNamed:@"empty.png"];
break;

 }
     }
    }


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-25T20:06:43+00:00Added an answer on May 25, 2026 at 8:06 pm

    You doing all of your cell configuration inside the if (cell == nil) statement. This code is only executed if the tableView did not return a cell from the dequeue method. What is probably happening is that you are re-using cells and they are not being configured, so the data and appearance remain the same.

    Your cellForRowAtIndexPath method should have the following structure:

    • Try to dequeue a cell
    • If no cell was returned, create a new cell and do any baseline configuration (this is the part inside your if (cell == nil) statement
    • Configure the cell (either the dequeued cell or your new cell) appropriately for the row. Bear in mind that the cell you are working on here could be a brand new cell or one that has previously been used.

    OK, based on your updated code, the problem appears to be that you are setting the favourite image, but you don’t unset it if the cell is no longer a favourite. You need an else to set that image to nil if the cell is not a favourite.

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

Sidebar

Related Questions

I have an iphone app. The view is consists of two children: a tableview
Right so I have a simple app that consists of a calendar a Set
in my app i have a list view. Each list consists of a image,
I have created a Custom View component and my layout file consists of a
I have an app which consists of three layers of view controllers: UITabBarController =>
My app consists of 3 views. I've defined 3 helper methods in the AppDelegate
I have an app which consists of several different assemblies, one of which holds
I have a small multiview app. It consists of a UITabBarController with a nav
My app consists of a TabBar and several TableViews. I want to have the
At the moment, I have a settings view in my iPhone app built with

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.