I want to have a simple SearchBar in ObjectiveC. Using UISearchBar
or UISearchBarDelegate
is confusing me. I could have used a UITextField
but it does not have the look & feel of a search bar.
As in the image attached, I want just the searchbar no UITableView
associated with it. The image has a TableView attached but you get the point. Also after someone enters text into the searchBar & pressed "enter" how do I retrieve the text?
UPDATE: I am aware of these links which discuss the same, but they are more in light with using tables.
http://blog.webscale.co.in/?p=228
http://ved-dimensions.blogspot.com/2009/02/iphone-development-adding-search-bar-in.html
Just make your view controller implement the
UISearchBarDelegate
. In your xib file, all you need to do is to add a UISearchBar to your view and configure it as necessary, create an outlet for it (optional really but helps to be explicit), and assign the delegate outlet to your view controller.Then, to respond to the search bar events, implement the
UISearchBarDelegate
protocol methods as necessary. For example: