UISearchBar in a UITableView
Posted
by petert
on Stack Overflow
See other posts from Stack Overflow
or by petert
Published on 2009-11-24T12:04:18Z
Indexed on
2010/06/18
7:23 UTC
Read the original article
Hit count: 848
uitableview
|iphone-sdk-3.0
|uitableviewcell
|uisearchbar
|uisearchdisplaycontroller
I'm trying to mimic the behaviour of a table view like one in the iPod app for Artists - it's a sectioned table view with a section index on the right and with a search bar at the top, but initially hidden when view shown.
I am using sdk 3.1.2 and IB, so simply dragged a UISearchDisplayController in to my NIB - it does wire everything up ready for searching. The problem starts because I'm adding the UISearchBar in to the first section of the UITableView, because if I understand correctly I must do this so I can jump to the search bar by touching the search icon in the section index directly? When the table view appears I see the search bar but it has resized and I now have a white block behind the section index at the top. It does'nt take the color of the UISearchBar's surround which interestingly is different to that shown in Interface Builder.
Searching around, I did find a tip to add a small navigation bar and a UISearchBar in a UIView, then add this to the table view cell - this works.. BUT the color of the navigation bar's background is what you'd expect normally (gray), not the different color as noted above?! More interesting, if I click the search bar to start a search, then click Cancel, all is fixed!!! The background along the whole tableview cell when the search bar is, is the same!!?!
Thanks for any tips.
© Stack Overflow or respective owner