title: Hide/Show a UITableView in iPhone?
body: <p>I need to show/hide a <code>UITableView</code> in some situations .But it is running absolutely fine sometimes.But sometimes <code>tableView</code> is not hidden.</p>
  
  <p>If array data is present I'm filling it in UITableView.But if the array is null I m displaying a label with text "Data not found"..This is working perfectly ,but if I repeatedly do it then on my TableView's data labels text is getting displayed without hiding the <code>tableView</code>..Couldn't understand where I m going wrong..</p>
  
  <p>This is the code I m writing...</p>
  
  <pre><code>if([arr count]==0)
  {
      lblError.text=@"";
      lblError  = [[UILabel alloc] init];
      [lblError setFrame:CGRectMake(0,390,320,200)];
      lblError.textAlignment=UITextAlignmentLeft;
      lblError.backgroundColor = [UIColor clearColor];
      lblError.text = @"Results not found";
      lblError.textColor = [UIColor redColor];
      lblError.shadowColor = [UIColor blackColor];
      lblError.font = [UIFont fontWithName:@"Verdana-Italic" size:15];      
      [self.view addSubview:lblError];
      tableView.hidden=YES;
      [tableView removeFromSuperview];
      tableView=nil;
  
   }
  else
  {
       sections=[[NSMutableArray alloc] init];
      for(int s=0;s&lt;1;s++)
      {
          NSMutableArray *section=[[NSMutableArray alloc] init];
          for(int i=0;i&lt;[arr1 count];i++)
          {
              Item *item=[[Item alloc] init];
              NSString *name=[[arr objectAtIndex:i]objectForKey:@"Name"];
              item.Name=name;
              [section addObject:item];
  
          }
          [sections addObject:section];
  
      }
      tableView=[[UITableView alloc]initWithFrame:CGRectMake(0,430,320,200) style:UITableViewStylePlain];
      tableView.delegate = self;
      tableView.dataSource = self;
      [self.view addSubview:tableView];  
      [tableView release];
  
  }
  </code></pre>