I'm trying to mimic the behaviour of a table view similar to the iPod app for Artists - it's a sectioned table view with a section index on the right, 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
into my NIB - it wires everything up for searching. The problem starts because I'm adding the UISearchBar
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 doesn't take the color of the UISearchBar
's surround which interestingly is different to that shown in Interface Builder.
I found 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 tap the search bar to start a search, then tap Cancel, all is fixed. The background along the whole tableview cell when the search bar is, is the same?
Put the search Controller in the beginning of the tableView and try this:
Answered my own question, but might be helpful to other beginners:
Update: use the string constant
UITableViewIndexSearch
string in place of the undocumented string "{search}" - i.e. return it as one of the array items when implementing:in UITableViewDataSource.