title: not able to set height of UITableView dynamic in objective c
body: <p>i created an iPad application, in which i used searchBar, in searchBar data is coming from database, and  i am storing it in an array called tableData.</p>
  
  <p>After this i am passing this tabledata array to tableView called myTableView, i declared height of table view in didLoad method.</p>
  
  <p>I want height of tableView to be dynamic according to number of elements in table,</p>
  
  <p>here is the code snippet,</p>
  
  <pre><code>- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
  {
      // only show the status bar’s cancel button while in edit mode
  
      sBar.autocorrectionType = UITextAutocorrectionTypeNo;
      // flush the previous search content
      [tableData removeAllObjects];
  }
  
  
  - (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
  {
      sBar.showsCancelButton = NO;
      [myTableView setHidden:TRUE];
  }
  
  
  - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
  {
      [myTableView setHidden:FALSE];
      [tableData removeAllObjects];// remove all data that belongs to previous search
      myTableView.backgroundColor=[[UIColor alloc]initWithRed:4.0 / 255 green:24.0 / 255 blue:41.0 / 255 alpha:1.0];
  
  
      [self.view bringSubviewToFront:myTableView];
  
      if([searchText isEqualToString:@""]||searchText==nil){
          [myTableView setHidden:TRUE];
          [myTableView reloadData];
          return;
      }
      NSInteger counter = 0;
      for(NSString *name in arr)
      {
          NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
          NSRange r = [name rangeOfString:searchText options:NSCaseInsensitiveSearch];
  
          if(r.location != NSNotFound)
          {
              if(r.location== 0)//that is we are checking only the start of the naames.
              {
                  [tableData addObject:name];
              }
          }
          counter++;
          [pool release];
      }
      [myTableView reloadData];
  }
  
  
  - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
  {
      // if a valid search was entered but the user wanted to cancel, bring back the main list content
      [tableData removeAllObjects];
  
      @try{
          [myTableView reloadData];
      }
      @catch(NSException *e){
      }
      [sBar resignFirstResponder];
      sBar.text = @"";
  }
  
  
  // called when Search (in our case “Done”) button pressed
  - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
  {
  
      [searchBar resignFirstResponder];
      [myTableView reloadData];
  }
  </code></pre>
  
  <p>declaration of myTableView in didLoad:</p>
  
  <pre><code>myTableView.frame=CGRectMake(550, 00, 220,400);
  </code></pre>
  
  <p>see screenshot,
  in first image data is there but, tableView doesn't increases it's size and in second image only 1 data is there but height is still fix.</p>
  
  <p><img src="https://i.imgur.com/LLa55.png" alt="screen">
  <img src="https://i.imgur.com/Kn7Jw.png" alt="screen"></p>