2013-10-17 69 views
2

當我在UISearchBar上啓動一個關於UITableView的子項的搜索時,除UITableView之外的任何其他視圖變爲隱藏。這個問題只發生在iOS 7上。我沒有隱藏其他視圖的任何特定代碼。UISearchBar隱藏在iOS 7中的視圖

enter image description here

enter image description here

enter image description here

enter image description here

回答

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; 
} 
0

嘗試在viewDidLoad中添加此爲酥料餅UIViewController

if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) 
    self.edgesForExtendedLayout = UIRectEdgeNone; 
+0

我給了一個嘗試,但我仍然看到相同的結果。但感謝你的迴應,即使你是一個老鷹迷...讓我們去牛仔! – MahmoudA