当我在作为 UITableView 的子项的 UISearchBar 上启动搜索时,除了 UITableView 之外的任何其他视图都将被隐藏。此问题仅发生在 iOS 7 上。而且我没有任何隐藏其他视图的特定代码。
问问题
1102 次
2 回答
3
要找到解决方案,我首先必须找出问题所在。
当文本输入到 UISearchBar 时,它会创建一个位于父视图顶部的 UITableView。要显示隐藏的父视图,创建的 UITableView 必须偏移并调整大小以适应较小的区域。
(void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView {
// The tableView the search tableView replaces
CGRect f = self.mainTableView.frame;
CGRect s = self.searchDisplayController.searchBar.frame;
CGRect updatedFrame = CGRectMake(f.origin.x,
f.origin.y + s.size.height,
f.size.width,
f.size.height - s.size.height);
tableView.frame = updatedFrame;
}
于 2013-10-18T17:41:24.467 回答
0
尝试在 popover 的 viewDidLoad 中添加它UIViewController
:
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
于 2013-10-17T16:06:14.327 回答