2012-03-08 110 views
0

我已將UISearchDisplayController添加到我的iPad應用程序,該應用程序正在管理UITableView(就像它應該這樣做)。但是我認爲UISearchDisplayController被着色的表格單元格深灰色,當搜索是無效的(例如,搜索欄的文字是零),像這樣:更改UISearchDisplayController外觀

UISearchDisplayController

有沒有一種辦法可以讓tableview看起來像正常(白色單元格),即使搜索欄是空的?

回答

1

你必須配置在searchDisplayController的SearchResultsTableView:didLoadSearchResultsTableView

例如:

-(void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView { 

    tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 
    tableView.rowHeight = 50.0f; 
} 

確保你已經設置searchDisplayController

+0

的代表恐怕這沒有幫助。在填充結果表時發送消息'didLoadSearchResultsTableView',但在搜索尚未開始時發送,而視圖爲空。例如。在上面的屏幕截圖中,當暗灰色表格視圖可見時,不會觸發'didLoadSearchResultsTableView'。一旦我在搜索框中輸入一個單詞,表格視圖就會變成白色,並觸發'didLoadSearchResultsTableView'。 – user826955 2012-09-30 12:00:52

+0

嘗試 - (void)searchDisplayController:(UISearchDisplayController *)控制器willShowSearchResultsTableView:(UITableView *)tableView或這個委託的一些 – Chakalaka 2012-10-01 08:40:38