2015-12-16 54 views
0

我有頁控制器,我添加了兩個tableviews。在添加tableview搜索控制器的每個頭部中,viewForHeader方法也會返回「Recent」和「Other」視圖。搜索欄不出現在ios

我的問題是搜索欄點擊時沒有出現搜索欄。 它似乎向上移動,我不能看到我在那裏打字。 搜索欄可能隱藏在「連接」,「消息」選項卡後面。

當鍵盤成爲第一響應者時,如何將搜索欄保持在同一位置? 任何幫助將不勝感激。

enter image description here

+0

爲了使子視圖到前臺,您可以使用'bringSubViewToFront'方法。 – sourav

+0

張貼圖片你看到搜索欄!使用視圖調試器來查看搜索欄是否在視圖後面!!! –

+0

此圖片點擊搜索欄後。其他明智它坐在最近和連接之間,消息 –

回答

1

具有u使用下面的代碼行的ViewDidLoad

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

[self.view bringSubviewToFront:searchBarRef]; // add this line where ever u need..! 

-(void)loadSearchBar { 

    searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 64)]; 
    searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; 
    searchDisplayController.delegate = self; 
    searchDisplayController.searchResultsDataSource = self; 

    self.tableView.tableHeaderView = searchBar; 

} 

調用此方法loadSearchBarViewDidLoad

這會將搜索欄添加到TableView

+0

試試上面的解決方案..!而不是每個標題視圖中的搜索控制器。 – Vidhyanand