我使用带有 tableView 的 UIViewController 。我已经设置了一个搜索控制器并将搜索栏嵌入到表视图标题中。当我搜索时,它会在 tableview 和上面的 uiview 之间留下一个状态栏大小的间隙。我意识到还有很多关于此的其他问题,但没有一个解决了这个问题。
这是设置搜索栏的代码:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = YES;
self.searchController.searchBar.delegate = self;
self.searchController.searchBar.backgroundImage = [UIImage new];
self.searchController.searchBar.backgroundColor = kBlueNavBarColor;
self.searchController.searchBar.tintColor = [UIColor whiteColor];
self.tableView.tableHeaderView = self.searchController.searchBar;
self.definesPresentationContext = YES;
我在展示时遇到了类似的问题UIViewController
模态地。导航栏升得太远了。我调整了导航栏的大小,使其更宽一些。让我知道这是否有帮助。此问题从 iOS 7 开始。您可能不需要检查版本。
float currentVersion = 7.0;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion) {
// iOS 7
self.navBar.frame = CGRectMake(self.navBar.frame.origin.x, self.navBar.frame.origin.y, self.navBar.frame.size.width, 64);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)