2010-07-28 19 views
6

I Actualmente esta pieza de código para crear un UISearchBar (adaptado de un ejemplo stackoverflow anterior):iPhone Objective-C añadiendo programación botones alcance a 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]; 

tengo que añadir 3 botones alcance a la parte inferior de la barra de herramientas: "Temas", "Mensajes", "Estaciones" y tiene el primero seleccionado por defecto. ¿Alguíen puede decirme como hacer esto, por favor?

Respuesta

15

Oh .. no importa .. .. lo encontraron

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

Puede aceptar su propia respuesta. – iDev

Cuestiones relacionadas