title: UITableView - inserting rows and scrolling to a specific section
body: <p>I have a tableview like..</p>
  
  <p><img src="https://i.stack.imgur.com/EhNJZ.png" alt="enter image description here"></p>
  
  <p>The cells xxxx, yyyy &amp; 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.</p>
  
  <p>So, after clicking the "Show" cell, the table will look like..</p>
  
  <p><img src="https://i.stack.imgur.com/ndojH.png" alt="enter image description here"> </p>
  
  <p>Here, what I done is,</p>
  
  <ul>
  <li><p>Changed <code>cell.textLabel.text</code> to "Show" to "Hide"</p></li>
  <li><p>Used <code>[tableView reloadData];</code> in <code>tableView:didSelectRowAtIndexPath:</code> method.</p></li>
  </ul>
  
  <p>My code is:</p>
  
  <pre><code>- (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];
      }
  }
  </code></pre>
  
  <p><strong>What I need:</strong></p>
  
  <ul>
  <li><p>I want to animate the cells when I click on the show/hide button. I come to know that, the method <code>insertRowsAtIndexPaths: withRowAnimation:</code>  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 <code>setEditing:animated:</code> or <code>tableView: commitEditingStyle: forRowAtIndexPath:</code> methods to do this?</p></li>
  <li><p>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..</p></li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/Nb9UZ.png" alt="enter image description here"></p>
  
  <p>Help needed.. I just confused!!</p>