Darthtong
Darthtong

Reputation: 1037

touchesEnded:withEvent: not being called from my UIView, which is on top of a UITableView

I have a UITableView and a UISearchBar in its header. When the user clicks in the UISearchBar I create a view (bg: black, alpha .65) and place it over the content in the UITableView. What I want is when the user clicks this semi transparent UIView is to resign the first responder from the UISearchBar. I have implemented touchesEnded:withEvent: in my UIViewController (is also my UITableView's controller) but this function never get called. Is there something I'm missing here?

Cheers,

Rob

Upvotes: 3

Views: 2598

Answers (3)

Ishu
Ishu

Reputation: 12787

You need to use UISearchBarController insted of UISearchBar,This having builtin functionality for what you looking for.

Upvotes: 0

ibnyadam
ibnyadam

Reputation: 45

i found a good link , may this link help you, download the source code for further help

Building a SearchView with UISearchBar and UITableView http://jduff.github.com/2010/03/01/building-a-searchview-with-uisearchbar-and-uitableview/

Upvotes: 0

murat
murat

Reputation: 4963

Your controller will only handle events of its own view, which is probably the table view. If you want to handle touch events in the view you have added later, you need to subclass UIView and implement touchesEnded:withEvent: method.

Upvotes: 1

Related Questions