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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:52:25+00:00 2026-06-13T04:52:25+00:00

I have a UITableView set up with a Core Data fetched results controller and

  • 0

I have a UITableView set up with a Core Data fetched results controller and custom cells created using a storyboard. Everything is working fine until I try conditionally setting the font color of a UILabel for some cells.

By default in the storyboard, each cell shows a “departure time” with a grey font. But, if the cell represents the user’s current location, the font should be blue. So I set up a conditional in configureCell (near the bottom of this snippet):

-(void) configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
    if ([cell isMemberOfClass:[SectionDividerCell class]])  {
        [self configureSectionDividerCell:(SectionDividerCell *)cell atIndexPath:indexPath];
    }
    else if ([cell isMemberOfClass:[VisitCell class]])  {
        [self configureVisitCell:(VisitCell *)cell atIndexPath:indexPath];
    }
}

-(void) configureVisitCell:(VisitCell *)cell atIndexPath:(NSIndexPath *)indexPath  {
    //Regular visit cell

    Visit *visit = [self.fetchedResultsController objectAtIndexPath:indexPath];

    //Set text content
    cell.titlePlace.text = visit.place_name;
    cell.arriveText.text = [visit getArrivalTimeDisplay:@"hh:mm a"];
    cell.leaveText.text = [visit getDepartureTimeDisplay:@"hh:mm a"];
    cell.durationText.text = visit.durationDisplay;

    //Set fonts
    [cell.durationText setFont:[UIFont fontWithName:@"Roboto-BoldCondensed" size:20.0]];
    [cell.arriveText setFont:[UIFont fontWithName:@"Roboto-Light" size:12.0]];
    [cell.titlePlace setFont:[UIFont fontWithName:@"Roboto-BoldCondensed" size:17.0]];

    //If current location, make text blue
    if (!visit.departure_time)    {
        [cell.leaveText setFont:[UIFont fontWithName:@"Roboto-Bold" size:12.0]];
        [cell.leaveText setTextColor:[UIColor blueColor]];
    }
    else    {
        [cell.leaveText setFont:[UIFont fontWithName:@"Roboto-Light" size:12.0]];

    }

    //Get Image for cell
    if (!cell.imgThumb.image)   {

        NSString *imageURL = [[docDir stringByAppendingString:@"/"] stringByAppendingString:visit.place.imageName];
        [cell.imgThumb setImage:[[UIImage alloc] initWithContentsOfFile:imageURL]];
    }

}

With the above code, the “Current Location” cell’s UILabel is correctly colored blue, but some other cells are also colored blue (seems to be random – happens to about 10% of the cells.

If I add this code within the else statement to set the color back to the default for cells that are not the current location, it fixes the problem:
[cell.leaveText setTextColor:[UIColor greyColor]];

But what I don’t understand is, why are some cells incorrectly having their font color set?

  • 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-13T04:52:26+00:00Added an answer on June 13, 2026 at 4:52 am

    Why are some cells incorrectly having their font color set?

    It’s not incorrect.

    If I add this code within the else statement to set the color back to the default for cells that are not the current location, it fixes the problem: [cell.leaveText setTextColor:[UIColor greyColor]];

    Yes, exactly. That’s because UITableView, for the sake of reducing memory footprint, re-uses table view cells. And when a cell is reused, UITableView doesn’t reset its properties, so You have to reset them to defaults. You can see this pattern in some code of mine, too, for example, this file browser UITableView shows symbolic links using light blue, but normal files in the default black color. Here you can also see the else branch of the conditional statement.

    // test for symlink
    if (readlink([childPath UTF8String], NULL, 0) != -1) {
        cell.textLabel.textColor = [UIColor colorWithRed:0.1f green:0.3f blue:1.0f alpha:1.0f];
    } else {
        cell.textLabel.textColor = [UIColor blackColor];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView Controller and a UITableView. I have everything set up using
Ok Guys, here's the situation I have. I'm using a UITableViewController with Core Data.
I am creating Travel guide app using core data. I have 4 entities CITY
I've got a UITableView set up and working, and now I have a little
I have a UITableView with some cells. When a cell is tapped, I set
I have a NSFetchedResultsController which displays data in a UITableView. I'm using the boiler
I'm using Core Data to cache a decent amount of information, and I have
I have a NSManageObject set up as an Entity in Core Data. After fetching
I have a parent-child Core Data relationship set up in my iPhone app. I
I have an UITableView set up with a NSArray with 10 indexes. Right now,

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.