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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:27:11+00:00 2026-05-22T22:27:11+00:00

I have a tableview that is blank by default. User can add cells to

  • 0

I have a tableview that is blank by default. User can add cells to it.

I want the separator lines to be clear when there are no cells, and grey when there are cells.

I am using this code:

if ([[self.fetchedResultsController fetchedObjects] count] == 0)
{
    self.routineTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.routineTableView.separatorColor = [UIColor clearColor];
}
else
{
    self.routineTableView.separatorColor = [UIColor grayColor];
}

The problem is, when I launch the app with a blank table, and if I add cells, the grey lines are not there there until I restart the app. But if I start with cells there, then delete them, then re-add them, the lines are there. Any suggestions?

  • 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-22T22:27:12+00:00Added an answer on May 22, 2026 at 10:27 pm

    Maybe you are missing this?

    ...
    else
    {
        self.routineTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; // or you have the previous 'None' style...
        self.routineTableView.separatorColor = [UIColor grayColor];
    }
    

    EDIT :
    You need this but not only this… According to Apple Documentation :

    The value of this property is one of the separator-style constants described in UITableViewCell Class Reference class reference. UITableView uses this property to set the separator style on the cell returned from the delegate in tableView:cellForRowAtIndexPath:.

    That means the style wont change for cells that are already loaded. Just scrolling the table to force cells to redraw should make separators appearing…

    You then have to :

    1. set it BEFORE cell is inserted

      OR

    2. reload tableView when the first cell is added

    which is not easy to do with a NSFetchedResultsController, you should look into its delegate for a solution… or change direction, like hiding the tableView until you have a result maybe…


    EDIT 2 : You can also simply add this :

    [self.tableView reloadData];
    

    but that’s a dirty workaround that will just reload full tableView, losing most benefits of NSFetchedResultsController…

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

Sidebar

Related Questions

I want to have a table view that is blank at start. The user
I have a grouped tableView with 5 sections and i want to add buttons
I have a tableView that shows a list of rss feeds in it's cells,
I have a grouped table view that utilizes two different custom table cells. When
In my application I have a tableview which a couple of cells on click
Ok, I have a grouped TableView that has the following overridden method: -(NSIndexPath*)tableView:(UITableView *)tableView
I have a tableview based app that downloads rss feeds from the web. So
I have created a table view that pulls its cells from an array. Each
I have tableview that scroll vertically. My question is when first this view is
I'm developping an android application. For that I need to have a dynamic tableView.

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.