gpt4 book ai didi

iphone - UISearchDisplayController 上方的白线

转载 作者:行者123 更新时间:2023-12-03 19:42:01 27 4
gpt4 key购买 nike

我的 uisearchdisplaycontroller 遇到问题。如果我将 Controller 的搜索栏添加到 TableView 标题 View 中,它会在搜索栏上方显示一条细白线!如果我添加搜索栏而不添加搜索 Controller ,它会正确显示。重要的是,您要仔细查看标准的 searchdisplaycontroller 或对其进行一些自定义,否则您将看不到该行。

有人知道避免白线的方法吗?

BaseViewController的init方法中的代码: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中的代码:viewWillAppear中的BaseViewController

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 有关,而不是与实现有关,因为如果你只使用搜索栏,一切都很好

最佳答案

设置searchBar.clipsToBounds = YES;

关于iphone - UISearchDisplayController 上方的白线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6200371/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com