Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

White line above UISearchDisplayController

I got a problem with the uisearchdisplaycontroller. If I add the controller's searchbar to a tableviews headerview it shows a thin white line above the searchbar! If I add the searchbar without the searchcontroller it shows it correctly. Important is that u take a really close look to the standard searchdisplaycontroller or customize it a bit, otherwise you will not be able to see the line.

Does anyone knows a way to avoid the white line?

Code in init methode of BaseViewController : UIViewController

   searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
   [searchBar sizeToFit];
   searchBar.showsCancelButton = NO;
   searchBar.barStyle = UIBarStyleDefault;
   searchBar.hidden = NO;

    searchBar.delegate = self;
    searchBar.placeholder = @"Suche";

    searchCtrl = [[UISearchDisplayController alloc]
                  initWithSearchBar:searchBar contentsController:self];
    searchCtrl.delegate = self;
    searchCtrl.searchResultsDataSource = self;
    searchCtrl.searchResultsDelegate = self;
    [searchCtrl searchResultsTableView].scrollsToTop = NO;

Code in StartViewController : BaseViewController in viewWillAppear

tableController.tableView.tableHeaderView = searchCtrl.searchBar;
searchBar.hidden = NO;

if ( [tableController.tableView contentOffset].y == 0.0 )
{
    [tableController.tableView setContentOffset:CGPointMake(0.0, 44.0) animated:NO];        
}

Nothing special, for me it has to do with the UISearchDisplayController not with the implementation, cause if u only use the searchbar everything is fine

like image 709
Andreas Grauel Avatar asked Jan 23 '26 03:01

Andreas Grauel


1 Answers

set searchBar.clipsToBounds = YES;

like image 159
dceballos Avatar answered Jan 24 '26 19:01

dceballos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!