views:

36

answers:

1

Hi,

I have a UISearchBar which is subviewed by another view when a button is pressed. When it loads, it looks like the following (minus the red scribbles):

alt text

I would like to have the UISearchBar view be removed from the parent view controller when the tableView (the area with red scribbles) is clicked and is empty (no search has been made yet). I'm having a difficult time figuring out the best way to do this.

I have tried to put a transparent button in that section and add it as a subview to the search bar. However the button is underneath the tabl view area, so when the table view is clicked, the search bar loses focus and the uibutton is only then accessible.

Does anyone know how I can remove the search bar from the parent view controller when the empty table view below it is clicked?

Thanks.

+1  A: 

To bring the transparent button up and make it catch all touched first, use [button.parentView bringSubViewToFront:button].

Another approach could be to catch the search bar losing focus (since you say you see that happening), by putting

– (void)searchBarTextDidEndEditing:(UISearchBar*)searchBar

in the search bar delegate, and handling it from there.

mvds