Search code examples
iosios7uisearchbar

UISearchBar scope bar invisible in iOS7


With the following code the scope bar is invisible (buttons work but are not visible - just black space)

UISearchBar* searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 44 + (_showScope?40:0));];
searchBar.barStyle = UIBarStyleBlack;

searchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"string1", @"string2", nil];
searchBar.showsScopeBar = YES;
searchBar.delegate = self;

self.tableView.tableHeaderView = searchBar;

works fine in iOS6. Any ideas?


Solution

  • this seems to be a workaround:

    UISearchBar* searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
    searchBar.barStyle = UIBarStyleBlack;
    
    searchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"string1", @"string2", nil];
    searchBar.showsScopeBar = YES;
    searchBar.delegate = self;
    
    self.tableView.tableHeaderView = searchBar;
    
    searchBar.frame = CGRectMake(0, 0, self.tableView.frame.size.width, 44 + (_showScope?40:0));
    

    nice!