2016-01-04 2 views
2

Am Использование UISearchController IOS 8, использовано ResultUpDating ДелегированиеSearch Bar IOS 8 - Отображение Два панели поиска

Приведенный ниже код

Методы
- (void)viewDidLoad { 

    [super viewDidLoad]; 

    self.products = [Product allProducts]; 

    // Create a mutable array to contain products for the search results table. 
    self.searchResults = [NSMutableArray arrayWithCapacity:[self.products count]]; 

    // The table view controller is in a nav controller, and so the containing nav controller is the 'search results controller' 
    UINavigationController *searchResultsController = [[self storyboard] instantiateViewControllerWithIdentifier:@"TableSearchResultsNavController"]; 

    self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController]; 

    self.searchController.searchResultsUpdater = self; 

    self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0); 

    self.tableView.tableHeaderView = self.searchController.searchBar; 

#if ENABLE_SCOPE_BUTTONS 

    NSMutableArray *scopeButtonTitles = [[NSMutableArray alloc] init]; 
    [scopeButtonTitles addObject:NSLocalizedString(@"All", @"Search display controller All button.")]; 

    for (NSString *deviceType in [Product deviceTypeNames]) { 
     NSString *displayName = [Product displayNameForType:deviceType]; 
     [scopeButtonTitles addObject:displayName]; 
    } 

    self.searchController.searchBar.scopeButtonTitles = scopeButtonTitles; 
    self.searchController.searchBar.delegate = self; 

#endif 

    self.definesPresentationContext = YES; 

} 

делегата

-(void)updateSearchResultsForSearchController:(UISearchController *)searchController{ 
    // Set searchString equal to what's typed into the searchbar 
    NSString *searchString = self.searchController.searchBar.text; 
    //NSLog(@"o"); 

    [self fetchByPatientName:searchString]; 



} 
- (void)fetchByPatientName:(NSString *)patientName 
{ 

//Code TO Fetch 

// Code To Update Table 

} 

Мои Stroy Совет [ enter image description here] [1

Aftr Ru nning Am Getting Two SearchBars, Am How How Slove It

Ваша помощь Просьба оценить.

enter image description here

ответ

0

Удаление следующее должно решить его

self.tableView.tableHeaderView = self.searchController.searchBar 
Смежные вопросы