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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:19:03+00:00 2026-06-07T06:19:03+00:00

Part of my iPhone app displays a UITableView with three, static sections in grouped

  • 0

Part of my iPhone app displays a UITableView with three, static sections in grouped format. However, in some instances (based on user input), it’s most appropriate for the last of these sections not to appear when the view controller displays the table.

In the viewDidLoad method of the controller, I’ve added the following lines of code that are executed conditionally:

if ([self.formula containsElementWithoutStableIsotopes]) {
    NSLog(@"Deleting section 2 ...");
    NSUInteger sectionToDelete = 2;
    [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionToDelete] 
                  withRowAnimation:UITableViewRowAnimationAutomatic];
}

“Deleting section 2 …” is logged to the console, so I know that this code is executing, but the table appears to be unaffected: all three sections are displayed as usual.

In the ideal case, I’d prefer section 2 to be deleted before the table view is even displayed, but I could live with it being deleted on appearing. However, if I place the code above within the viewDidAppear method instead, the program raises an NSInternalInconsistencyException because the number of sections before and after deletion do not match.

I’d really appreciate your help on this topic.

  • 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-07T06:19:05+00:00Added an answer on June 7, 2026 at 6:19 am

    Please use the following code below:

    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
        sectionToDelete = 1;
        [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionToDelete] withRowAnimation:UITableViewRowAnimationFade];
        [self.tableView reloadData];
    
    }
    
    
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        // Return the number of sections.
        return 3 - numberOfSectionsToDelete;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an iPhone app that, in part, allows the user to log in
Some Background I have an iPhone app with three UIWebViews, each used to show
I've been developing my first iPhone app part-time and would like to start using
As part of the development phase of my iPhone app it would be really
I'm currently making an iPhone app that has PDF viewing a crucial part of
I'd like to use some fonts that aren't part of the iPhone OS. I've
There is a part of the iPhone app that I'm developing where you can
I have a navigation based iPhone app. When you press on a cell in
I'm totally new to Mac OS and iPhone and I'm writing some small app.
My iPhone app uses core data and things are fine for most part. But

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.