title: Hide UIButton added in UITabBarController from child ViewController
body: <p>I have a TabBar application, which I have added a UIButton too, which brings up a menu.</p>
  
  <p>This is how the menu button is added to the Tab Controller:</p>
  
  <pre><code>//TabBarViewController.m
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
      menuBtn.frame = CGRectMake(285, 28, 24, 24);
      [menuBtn setBackgroundImage:[UIImage imageNamed:@"menu.png"] forState:UIControlStateNormal];
      [menuBtn addTarget:self action:@selector(showMenu:) forControlEvents:UIControlEventTouchUpInside];
  
      [self.view addSubview:self.menuBtn];
  }
  </code></pre>
  
  <p>This functions fine and produces the following:</p>
  
  <p><img src="https://i.stack.imgur.com/fF8Al.png" alt="The button is visible and working in the top right corner."></p>
  
  <p><em>I have the button in the Tab Bar Controller so it shows on each tab.</em></p>
  
  <p>This all works fine, but when I use the search bar the menu button becomes in the way:</p>
  
  <p><img src="https://i.stack.imgur.com/ns7Vh.png" alt="Button is now covering the cancel button."></p>
  
  <h2><strong>How would I be able to hide the menu button while the search is active?</strong></h2>
  
  <p>I have worked out how to detect when the search bar is active, but I am having trouble trying to hide the menu button.</p>
  
  <pre><code>//SearchViewController.m
  
  - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
      TabBarViewController *vc = [[TabBarViewController alloc]init];
      [vc.menuBtn setHidden:YES];
  }
  
  - (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar {   
      TabBarViewController *vc = [[TabBarViewController alloc]init];
      [vc.menuBtn setHidden:NO];
  }
  </code></pre>
  
  <p>I have tried a few methods, but nothing is able to hide the menu button. Is this impossible, or am I missing something?</p>
  
  <p>Any help would be much appreciated, Thanks</p>