我使用的是带有iOS7新功能displaysSearchBarInNavigationBar和不透明导航栏的UISearchDisplayController。搜索显示控制器似乎错误地定位了视图。
我试着插入委托方法和重新定位,但我不能得到正确的初始位置,也不能在旋转时。此外,这似乎是一个草率的解决方案。
发布于 2014-04-03 22:50:55
只需在你的视图控制器的故事板中启用“在不透明条下”,或者如果你想添加下面的lines.Your code.Then :)
self.edgesForExtendedLayout = UIRectEdgeAll;
self.extendedLayoutIncludesOpaqueBars = YES;
发布于 2013-12-05 11:46:26
我也有同样的问题,在寻找了几个小时的答案后,我决定查看视图层次结构。看起来searchBar的超级视图,也是暗淡的视图,它的y原点是64,高度是504,这并没有占据整个屏幕。不知道为什么会这样。尽管如此,我最终还是将y设置为0,并将其高度设置为屏幕高度。在此之后,我将其y设置回原始值,否则您的内容表视图将被扭曲。这不是最好的解决方案,但总比没有好。希望这对你有帮助。
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller {
self.savedSearchTerm = nil;
UIView *dimmedView = controller.searchBar.superview;
CGRect frame = dimmedView.frame;
frame.origin.y = 64;
dimmedView.frame = frame;
[self.tableView reloadData];
}
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
UIView *dimmedView = controller.searchBar.superview;
CGRect frame = dimmedView.frame;
frame.origin.y = 0;
frame.size.height = 568;
dimmedView.frame = frame;
}
发布于 2016-08-15 15:06:16
1.使用显示,找到覆盖层,发现是_UISearchDisplayControllerDimmingView
2.找到图层,修改相应的框架,可以通过调光视图与同一视图的searchResultsTableView子层在地图上找到。
- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller {
for(UIView * v in controller.searchResultsTableView.superview.subviews)
{
if([v isKindOfClass:[NSClassFromString(@"_UISearchDisplayControllerDimmingView") class]])
{
v.frame = CGRectMake(0,20,320,400); // modify the frame
NSLog(@"--------- %@",[v class]);
}
}
3.类似地,如果您需要调整searchResultsTableView框架,请将以下代码附加到
- (void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView
{
tableView.frame =CGRectMake(0, 20, 320, 480-64-44);
}
https://stackoverflow.com/questions/19039212
复制相似问题