+1  A: 

You can override the touchesBegan method of the UITableView then run a hit test.

Then ask the view returned what class it is.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

CGPoint location = [[touches anyObject] locationInView:self]; 

UIView *whatIsThis = [self hitTest:locationInView withEvent:event];

NSLog([[whatIsThis class] description]);


}

At least you'll have a starting point. You could also ask who its superView is as well.

Corey Floyd
It's an UITableView, and its superview is View.
Stephan Burlot
Now you know it isn't a cell and it isn't the table header or section header. I'm not sure those are the answers you wanted, but may allow you to track down the bug
Corey Floyd
A: 

So I found the solution to my problem:

Adding an NSLog(@""). This is weird.

In my viewWillAppear, I have

  if (searchByCuisinier || searchByResto) {
    NSLog(@"Will set tableHeaderView");
    self.tableView.tableHeaderView = searchBar;
    if (searchByCuisinier) {
      searchBar.placeholder = @"Cuisinier";
    } else {
      searchBar.placeholder = @"Restaurant";
    }
    searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
    searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
    if ([filteredList count] == 0)
      [searchBar becomeFirstResponder];
  } else {
    self.tableView.tableHeaderView = nil;
    NSLog(@""); // Magic!
  }

Adding the NSLog(@"") solves the bug.

Also reversing the test: Instead of

  if (searchByCuisinier || searchByResto) {
....

I do:

  if (!searchByCuisinier && !searchByResto) {
....

I have absolutely no idea why this works (or why it doesnt work without the NSLog).

Stephan Burlot