Question

is there any easy way in the iPhone SDK to include search bars like those in the iPod app or in the Contacts app? (They behave and look unlike the usual UISearchBars ...)

-- Ry

Was it helpful?

Solution

Check out UISearchDisplayController. It handles the repositioning of the search bar, the graying of the screen, etc, etc, etc.

UIViewController has a UISearchDisplayController property, so it's pretty easy to hook up. There's also the TableSearch sample code.

OTHER TIPS

This adds a search bar to a table view as the header view. This means that it scrolls with the table view:

- (void) viewDidLoad
{
    [super viewDidLoad];
    UISearchBar* searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake(0, 0, 320, 45)];
    if (searchBar != nil) {
        // Your UISearchBar specifics here
        self.tableView.tableHeaderView = searchBar;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top