views:

54

answers:

1

I have a table view with a search bar above it, and when the search bar is pressed I want the table view to become inactive. So I have this method:

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
    self.tableView.userInteractionEnabled = NO;
}

with the same class being the UISearchBarDelegate. For some reason though it doesn't disable the table view. Any thoughts? Let me know if there's any other pieces of code needed to help. Thanks.

A: 

Not sure why userInteractionEnabled is not making your UITableView inactive, but I can suggest an alternative approach.

I recently moved a project over from manually adding a UISearchBar as a subview of my UITableView to using a UISearchDisplayController. I can definitely recommend doing it this way. The SearchDisplayController will animate in a alpha blended view behind the search bar which prevents interaction with the underlying table view, which would avoid the problem you are having.

Update:

This might be something to do with the way you are adding your UISearchDisplayController. Does your view hierarchy look like this?

alt text

Cannonade
I am using a UISearchDisplayController, it still doesn't prevent user interaction for me. Not sure why.
marty
@marty Ok, that is weird. You should get a a semi-transparent view that pops up over your tableview when you call UISearchDisplayController setActive. Are you loading the UISearchDisplayController in code or from the XIB?
Cannonade