我对UIsearchBarController
没什么问题。当我点击时
搜索栏在导航栏上始终显示白色。我想要那里的导航栏。
- (void)viewDidLoad {
[super viewDidLoad];
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)])
{
[self setEdgesForExtendedLayout:UIRectEdgeNone];
}
}
-(void)viewDidAppear:(BOOL)animated
{
[self addSearching];
}
-(void)addSearching
{
searchResultsController = [[UITableViewController alloc] init];
searchResultsController.tableView.delegate = self;
searchResultsController.tableView.dataSource = self;
searchResultsController.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
searchResultsController.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
searchResultsController.tableView.delegate = self;
searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
searchController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
searchController.delegate = self;
searchController.searchResultsUpdater = self;
searchController.searchBar.delegate = self; // so we can monitor text changes + others
searchController.searchBar.placeholder = @"Search Members";
[searchController.searchBar sizeToFit];
//self.definesPresentationContext = YES; // know where you want UISearchController to be displayed
self.memberTableView.tableHeaderView = searchController.searchBar;
}
输出是: