title: UISearchDisplayController CGContext Error iOS 7
body: <p>I am using a UISearchDisplayController in my app. Since iOS 7 a strange bugg occurs, when  klicking on the searchBar and the keyboard is displayed, the app gives several errors if the user decides to klick at the searchBar once more while the "searchField" is empty.</p>
  
  <p>The bugg is discussed in this thread: <a href="https://stackoverflow.com/questions/17777928/uisearchbar-cgcontext-error">UISearchBar CGContext ERROR</a></p>
  
  <p>Now I have 2 questions: is there any way to solve tihs problem? And if not, can you upload the app to the App Store with this bugg in the system? </p>
  
  <p>Regards</p>
  
  <p>My code:</p>
  
  <pre><code>- (void)viewDidLoad
  {
  [super viewDidLoad];
  
  
  if ([self systemVersionGreaterThanOrEqualTo:@"7.0"])
  {
  
      [[UISearchBar appearance]setSearchFieldBackgroundImage:[UIImage imageNamed:@"searchbar_bg"] forState:UIControlStateNormal];
      self.navigationItem.titleView = searchBar;
  }   
  }
  
  - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
  
  [self.searchDisplayController setActive:YES animated:NO];
  
  // Hand over control to UISearchDisplayController during the search
  // searchBar.delegate = (id &lt;UISearchBarDelegate&gt;)self.searchDisplayController;
  return YES;
  }
  
  - (void) searchDisplayControllerDidBeginSearch:(UISearchDisplayController
                                              *)controller {
  // Un-hide the navigation bar that UISearchDisplayController hid
  [self.navigationController setNavigationBarHidden:NO animated:NO];
  }
  
   - (void) searchDisplayControllerWillEndSearch:(UISearchDisplayController
                                             *)controller {
  searchBar = (UISearchBar *)self.navigationItem.titleView;
     // Manually resign search mode
  [searchBar resignFirstResponder];
  // Take back control of the search bar
  searchBar.delegate = self;
  }
  </code></pre>