2011-09-27 49 views
0

它的所作所爲在UISplitViewController的RootViewController的 -有什麼辦法可以爲UISplitViewController RootViewController實現不可滾動的頭文件嗎?

UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 0)]; 
    [searchBar setPlaceholder:@"Search within application"]; 
    searchBar.delegate = self; 
    [searchBar sizeToFit]; 
    searchBar.tintColor=[[UIColor alloc] initWithRed:212.00/255 green:236.00/255 blue:256.00/255 alpha:1.0 ]; 

    self.tableView.tableHeaderView = searchBar; 
    [searchBar release]; 

它的正常工作,但是當我們滾動的tableview搜索欄也與實現代碼如下行移動。

我想實現對用戶始終可見的搜索欄。

我可以嘗試使用SearchDisplayController,但在UISplitViewController中,我們沒有獲取RootViewController的.xib文件。

請幫我解決這個問題。

回答

0

您可以將您的搜索欄添加到導航控制器的導航欄中。下面是步驟:

  1. 變化導航欄的通過將搜索條的高度,以它的frame.origin.height幀。
  2. 添加搜索欄作爲一個子視圖
  3. 變化類控制器的viewUIView(假設它現在是一個表視圖是),並添加一個新的子視圖UITableView的,調節框架根據搜索欄高度。
  4. 用控制器重新連接新的tableView(delegate,datasource,tableView outlet)。

這對我有效。

相關問題