2011-06-01 30 views
3

我遇到了uisearchdisplaycontroller的問題。 如果我將控制器的搜索欄添加到tableviews headerview,它會在搜索欄上方顯示一條細白線!如果我在沒有searchcontroller的情況下添加搜索欄,它會正確顯示它。重要的是,你需要仔細看看標準的searchdisplaycontroller或定製它,否則你將無法看到該行。UISearchDisplayController上方的白線

有沒有人知道避免白線的方法?

守則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; 

守則StartViewController:BaseViewController在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];   
} 

沒什麼特別的,對我來說它做的UISearchDisplayController不與實施,因爲如果你只使用搜索欄一切都很好

+0

也許你應該粘貼一些代碼.. – 2011-06-01 11:29:05

回答

4

set searchBar.clipsToBounds = YES;

+0

爲我工作!謝謝! – Anthony 2013-01-09 22:09:50