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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:11:01+00:00 2026-06-09T04:11:01+00:00

I have a tableview like.. The cells xxxx, yyyy & zzzz are fixed, so

  • 0

I have a tableview like..

enter image description here

The cells xxxx, yyyy & zzzz are fixed, so that, there is no click action to them. But the cell “Show” is clickable. I want to show some six cells under the “Show” cell when it is clicked.

So, after clicking the “Show” cell, the table will look like..

enter image description here

Here, what I done is,

  • Changed cell.textLabel.text to “Show” to “Hide”

  • Used [tableView reloadData]; in tableView:didSelectRowAtIndexPath: method.

My code is:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"My title";
    // This Mutable array contains the hided cell objects
    hidedCellsArray = [[NSMutableArray alloc] initWithObjects:@"Cell 1", @"Cell 2", @"Cell 3", @"Cell 4", @"Cell 5", @"Cell 6", nil];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
...

else if(indexPath.section == 1)
    {
        if (isShowClicked) //isShowClicked is a boolean value that determines whether the show cell was clicked or not
        {
            if (indexPath.row == 0)
            {
                cell.textLabel.text = @"Hide";
                cell.selectionStyle = UITableViewCellSelectionStyleBlue;
                cell.textLabel.textAlignment=UITextAlignmentCenter;
            }

            else
            {
                cell.textLabel.text = [hidedCellsArray objectAtIndex:indexPath.row-1];
                cell.selectionStyle = UITableViewCellSelectionStyleBlue;
                cell.textLabel.textAlignment=UITextAlignmentCenter;
            }
        }

        else
        {
            cell.textLabel.text = @"Show";
            cell.selectionStyle = UITableViewCellSelectionStyleBlue;
            cell.textLabel.textAlignment=UITextAlignmentCenter;
        }
    }
...
return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    if (indexPath.section == 1)
    {
        if (isShowClicked)
        {
            isShowClicked = NO;
        }

        else
        {
            isShowClicked = YES;
        }

        [tableView reloadData];
    }
}

What I need:

  • I want to animate the cells when I click on the show/hide button. I come to know that, the method insertRowsAtIndexPaths: withRowAnimation: should be used to achieve the insertion effect. But I really don’t see any simple example for this. Should I include any other methods like setEditing:animated: or tableView: commitEditingStyle: forRowAtIndexPath: methods to do this?

  • The second thing is, before the animation (cell insertion) happen, I want to move the tableview to section 2 (That is, the “show” cell) to the top. Then the animation of inserting cells should be happen. So, the final appearance of the table after clicking the show cell should like..

enter image description here

Help needed.. I just confused!!

  • 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-09T04:11:03+00:00Added an answer on June 9, 2026 at 4:11 am

    For the first part, you can check “Batch Insertion, Deletion, and Reloading of Rows and Sections” section under Table View Programming Guide for iOS. The most important thing is you need to make sure your data source is matched with the change.

    For the second problem, you can set the contentOffset of the table view to the point of the origin of second section title. Something like:

    self.tableView.contentOffset = CGPointMake(0, [self.tableView rectForSection:1].origin.y);
    

    If you want to use animation for better UE, just do

    [UIView animateWithDuration:duration animations:^{
        //Move table view to where you want
    } completion:^(BOOL finished){
        //insert rows when table view movement animation finish
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a performance issue in my tableview my cellForRow looks like that: if
I have a searchable tableview, but would like to only display the number of
I have a Tableview containing cells with images, however the cells that are reused
I have a tableView that shows a list of rss feeds in it's cells,
I have the following: I would like to make it so that the tableview
I have a tableview that has groups. I would like to add a dummy
I have a tableview that has a large number of fairly tall dynamic cells.
I have a tableView where the cells are movable. In edit mode, that brings
In a tableview I have on every cell a UILongPressGestureRecognizer which I add like
I have a UISwitchView on every tableview cell, and would like to allow 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.