title: How to display and hide table on button click in iOS?
body: <p>I have a view controller. In view there is button "show/hide". When I click on this button table should display and when I click on this button again table should hide.</p>
  
  <p>I'm using following code:</p>
  
  <pre><code>-(void)imageTapped:(UIButton *)sender
  {
      buttonclk=TRUE;
      if (buttonclk==TRUE)
      {
          [self addTableView];
          buttonclk=FALSE;
      }
      else
      {
          tableView1.hidden=YES;
      }
  }
  
  -(void)addTableView
  {
      CGRect fr = CGRectMake(0,176,320,500);
  
      tableView1 = [[UITableView alloc] initWithFrame:fr style:
                    UITableViewStylePlain];
      tableView1.autoresizingMask = UIViewAutoresizingFlexibleHeight|
                                    UIViewAutoresizingFlexibleWidth;
      tableView1.delegate = self;
      tableView1.dataSource = self;
      tableView1.separatorColor = [UIColor darkGrayColor];
      [self.view addSubview:tableView1];
  }
  </code></pre>
  
  <p>When I use this code table is displaying but not hiding.</p>