2010-07-28 12 views
6

Attualmente questo pezzo di codice per creare un UISearchBar (adattato da un precedente esempio StackOverflow):iPhone Objective-C programmazione aggiunta di pulsanti portata ad un UISearchBar

UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero]; 
    [searchBar sizeToFit]; 

    //searchBar.delegate = self; 
    searchBar.placeholder = @"Search messages, listeners or stations"; 
    self.tableView.tableHeaderView = searchBar; 

    UISearchDisplayController *searchDC = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; 

    // The above assigns self.searchDisplayController, but without retaining. 
    // Force the read-only property to be set and retained. 
    [self performSelector:@selector(setSearchDisplayController:) withObject:searchDC]; 

    //searchDC.delegate = self; 
    //searchDC.searchResultsDataSource = self; 
    //searchDC.searchResultsDelegate = self; 

    [searchBar release]; 
    [searchDC release]; 

Ho bisogno di aggiungere 3 pulsanti portata al fondo della barra degli strumenti: "Argomenti", "Messaggi", "Stazioni" e il primo selezionato per impostazione predefinita. Qualcuno può dirmi come farlo?

risposta

15

Oh .. non importa .. l'ho trovato ..

searchBar.showsScopeBar = YES; 
searchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"Flags", @"Listeners", @"Stations", nil]; 
+0

È possibile accettare la propria risposta. – iDev

Problemi correlati