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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:51:29+00:00 2026-05-23T11:51:29+00:00

i am implementing a grouped table view in my application, where user can select

  • 0

i am implementing a grouped table view in my application, where user can select row from different section of table.

i want to hide(remove) particular section(including header) depending upon selection of row of first section.

i.e.

first sections header is “Do you own car?”, answer would be YES or NO in row selection.
if user selects NO, second and third section from grouped table should hide(remove).

for radio selection in grouped table, i implement this

i also refer this but does not full fill what i need.

Please help.

Edit

TableViewDelegates

myArray is my datasource.
myArrayAnswerCount contains count of number of row per section

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [myArray count];
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    for (int i = 0; i<[myArray count]; i++) {
        if (section==i) {
            return [[myArray objectAtIndex:i] title];
        }
    }
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    for (int i = 0; i<[myArray count]; i++) {
        if (section==i) {
            return [[myArrayAnswerCount objectAtIndex:i] intValue];
        }
    }
}

this is code for how i removes section from table,
myIndexPath is NSIndexPath variable which is pointing to section which is currently selected.

[table beginUpdates];
[myArray removeObjectAtIndex:myIndexPath.section];
[table deleteSections:[NSIndexSet indexSetWithIndex:myIndexPath.section] withRowAnimation:YES];
[table endUpdates];
  • 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-23T11:51:29+00:00Added an answer on May 23, 2026 at 11:51 am

    I solved my question.

    [table beginUpdates];
    [myArray removeObjectAtIndex:myIndexPath.section];
    [table deleteSections:[NSIndexSet indexSetWithIndex:myIndexPath.section] withRowAnimation:UITableViewRowAnimationRight];
    [table endUpdates];
    

    The issue in “invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (3)” error was i forgot to remove object from myArrayAnswerCount array too.

    so finally following code

    [table beginUpdates];
    [myArray removeObjectAtIndex:myIndexPath.section];
    [myArrayAnswerCount removeObjectAtIndex:myIndexPath.section]; //this is what i forgot.
    [table deleteSections:[NSIndexSet indexSetWithIndex:myIndexPath.section] withRowAnimation:UITableViewRowAnimationRight];
    [table endUpdates];
    

    thanks.

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

Sidebar

Related Questions

When implementing the ViewModel in a Model-View-ViewModel architecture WPF application there seem to be
Implementing Document-View pattern I faced the problem: standard generic collections and dictionaries ( List<T>
Whilst implementing my first MVVM application in WPF, I've been wondering about the pros
Im implementing NFS and almoste done but the RFC section 3.3.8 says this in
Implementing ArrayAccess Interface in PHP , We can access Object Properties as Array Keys
I implementing OLE DB provider for my custom database. It will be used from
While implementing the code from this question on my project I realized there's 3
I've recently started creating a WPF application, and am just hoping that someone can
I need to produce different WARs from a Maven project, according to values that
I'm implementing namespaces in my existing project. I found that you can use the

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.