开发者

Remove UISearchBar on tableView click

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):

Remove UISearchBar on tableView click

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 开发者_如何学JAVAthe 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜