4m1*_*m1r 8 uinavigationbar uitableview ios8 uisearchcontroller
当我开始在UISearchController.searchBar中输入时,我试图找出为什么我的整个导航栏消失了它正确加载并动画正确,但是当我开始输入时我失去了活动的NavBar.这是从viewDidLoad加载searchController的代码:
UITableViewController *searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
searchResultsController.tableView.dataSource = self;
searchResultsController.tableView.delegate = self;
searchResultsController.tableView.backgroundColor = [UIColor redColor];
self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
self.searchController.delegate = self;
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = YES;
self.searchController.hidesNavigationBarDuringPresentation = NO;
[self.searchController.searchBar sizeToFit];
self.tableView.tableHeaderView = self.searchController.searchBar;
self.definesPresentationContext = NO;
Run Code Online (Sandbox Code Playgroud)
这是我开始输入后的结果:

注意表格视图是如何存在的,但它似乎占据了导航控制器的空间并向下延伸到第一部分标题中.有任何想法吗?
谢谢.
您需要将definePresentationContext设置为YES。以苹果为例:
// Search is now just presenting a view controller. As such, normal view controller
// presentation semantics apply. Namely that presentation will walk up the view controller
// hierarchy until it finds the root view controller or one that defines a presentation context.
self.definesPresentationContext = YES
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1557 次 |
| 最近记录: |