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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:03:20+00:00 2026-06-16T22:03:20+00:00

I put message no results when my tableview is empty. the problem is that

  • 0

I put message “no results” when my tableview is empty.
the problem is that when I have 1 row and I want to delete this row number of rows
don’t change because I have if condition that show me “no results” use row,
I can make bool property that check if deleted and then if user delete this row that will not show him message “no results”, but maybe someone have better way?

my methods:

num of sections:

if([[[self fetchResultsController] fetchedObjects] count] == 0)
        return 1;

rows in section:

if([[[self fetchResultsController] fetchedObjects] count] == 0)
        return 1;

cell:

if([[[self fetchResultsController] fetchedObjects] count] == 0){

        [[cell textLabel] setText:@"no results"];

    }else{ //create regular or from search 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-06-16T22:03:22+00:00Added an answer on June 16, 2026 at 10:03 pm

    The best solution that I find is make a title instead of cell to avoid problems with delete and update (core data). but title as I know can’t appear if there no rows or sections. So I solute it with this two methods:

    -(void) hideTitle{
        self.tableView.tableHeaderView = nil;
    }
    
    -(void) showTitle{
    
        self.contener = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 40)];
        self.label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 40)];
    
        self.label.text = NSLocalizedString(@"Header for the table", @"");
        self.label.shadowOffset = CGSizeMake(0, 1);
        self.label.font = [UIFont boldSystemFontOfSize:22];
        self.label.backgroundColor = [UIColor redColor];
        [self.contener addSubview:[self label]];
        self.tableView.tableHeaderView = self.contener; 
    }
    

    I put this one named show at the num_of_sections..:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        if([[[self fetchResultsController] fetchedObjects] count] == 0)
            [self showTitle];  .....}
    

    this method works well when delete rows.
    the second method named hide I use when I create new row (I put the method in my “save method”) this method delete the title.

    edit:
    another way:

    As I try before num of row…

    if([[bla bla] count] == 0 && is_deleted == 0)
            return 1;
    

    change cell too:

    if([[bla bla] count] == 0){
    
        [[cell textLabel]setText:@"no results"];
        [[cell detailTextLabel] setText:nil];
    
        cell.accessoryType = UITableViewCellSelectionStyleNone;
        cell.userInteractionEnabled = NO;
    
    }else{ 
    
      cell.userInteractionEnabled = YES;
      cell.accessoryType = UITableViewCellSelectionStyleBlue;
    
     ... }
    

    the issue id a delete row so I use bool to avoid crush at didLoad method bool = 0;
    when I delete I insert 1 to the bool don’t forget cancel the delete option for this cell!!

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
        {
            if (editingStyle == UITableViewCellEditingStyleDelete && [[bla bla] count] != 0)
            { ... }
    

    the problem with this solution that it’s not perfect, when I delete the last row my tableView is empty only when I load table again the title appear that not what I want.

    If someone have more elegant solution please tell me I promise check your answer as correct answer.

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

Sidebar

Related Questions

I've put this together through scripts that I have found online, but I'm not
I want to put out an error message when the uploaded image size is
How do I save a message in the SMS inbox? I want to put/save
I have a Login that is initiated on the viewDidLoad of the mainApp. This
I have an object that when you instantiate it and send it a message
Have a problem. I have a file which contents look like number:error_description . Now
I have a very similar problem to the one described in this question .
I have a php script does this: Put UPC into form Submit form Check
This is a simplified version of my problem: On the server we have n*m
I don't understand why I have this error. When I use newRequest, I have

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.