【发布时间】:2015-10-08 09:15:32
【问题描述】:
我在UINavigationBar 中有一个UITableView 和一个UISearchController 搜索栏,一切正常,但是当我推送UISearchController 的搜索结果的结果时,我回来UITableView 在下面NavBar,这就是我初始化UISearchController的方式:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.delegate = self;
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.searchController.searchBar.placeholder = NSLocalizedString(@"Local Search", @"");
self.searchController.searchBar.frame = CGRectMake(0, -5, [UIScreen mainScreen].bounds.size.width, 44);
ctrl = [[UIView alloc] initWithFrame:CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width, 44)];
ctrl.backgroundColor = [UIColor clearColor];
ctrl.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[ctrl addSubview:self.searchController.searchBar];
self.navigationItem.titleView = ctrl;
self.definesPresentationContext = YES;
搜索栏完美地显示在UINavigationBar 中,然后当我搜索某些内容并推送一个结果的视图控制器时,如下所示:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
DetailListController *detailList = [[DetailListController alloc] init];
[self.navigationController pushViewController:detailList animated:YES];
}
当我回到UITableView 这样做时:
[self.navigationController popViewControllerAnimated:YES];
UITableView 在UINavigationBar 下,我该如何解决这个问题?
谢谢
【问题讨论】:
标签: ios objective-c uitableview uinavigationbar uisearchcontroller