title: iOS 7: How to hide the DONE button on the keyboard
body: <p>I'm trying to give my users a way to dismiss the keyboard, whether by clicking outside the keyboard or by having a DONE button on the keyboard itself.</p>
  
  <p>I have created a Done button and it works fine on iOS 6:</p>
  
  <pre><code>UIToolbar *keyboardToolbar;
  
  keyboardToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - 44, 320, 44)];
  
  UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
  UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"dismiss_keyboard", nil) style:UIBarButtonItemStyleDone target:self action:@selector(dismissKeyboard)];
  
  NSArray *items = [NSArray arrayWithObjects:flexItem,doneItem, nil];
  [keyboardToolbar setItems:items animated:YES];
  
  for (UIView *subview in [searchBar subviews]) 
  {
  
      if( [subview isKindOfClass:[UITextField class]] )
      {
          ((UITextField*)subview).delegate=self;
          ((UITextField*)subview).inputAccessoryView = keyboardToolbar;
          break;
      }
  
  }
  </code></pre>
  
  <p>But on iOS 7 this button is no where to be found.</p>
  
  <p>I also tried using the method where the user can click anywhere but the keyboard and make it disappear:</p>
  
  <pre><code>-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  {
  
      [super touchesBegan:touches withEvent:event];
  
      //Code to dismiss keyboard.
  }
  </code></pre>
  
  <p>But my view contains a <code>UISearchBar</code> and a <code>UITableView</code> but the <code>touchesBegan</code> event doesn't fire when I touch those, only when I touch the parent UIView, which is not visible because it's covered by my <code>UISearchBar</code> and my <code>UITableView</code>. I have to touch the tiny space in between the two to fire the event.</p>
  
  <p>How can I make my <code>touchesBegan</code> method apply to any object on the screen? And why is my DONE button not showing up in iOS 7?</p>