0
我試圖讓我的searchResultsTableView
內返回的單元格看起來與「常規」,非搜索表格視圖中的單元格相似。這是我的regular view。獲取多個表視圖實例以匹配
第一次搜索時,結果的樣式與「常規」表格視圖完全相同。但是,一旦您取消了searchDisplayController並再次點擊搜索按鈕,you'll get this。
它看起來像在第一次加載搜索顯示控制器後沒有設置背景。
我使用UITableViewCell
實例化tableView:cellForRowAtIndexPath:
中的單元格,而不是自定義子類。下面是該方法的其餘部分:
PersonInfo *info = nil;
if (tableView == self.searchDisplayController.searchResultsTableView) {
info = [self.filteredPeopleList objectAtIndex:indexPath.row];
} else {
info = [self.peopleList objectAtIndex:indexPath.row];
}
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellBk.png"]];
cell.detailTextLabel.textColor = [UIColor whiteColor];
cell.backgroundColor = [UIColor clearColor];
cell.imageView.image = info.image;
cell.textLabel.text = info.name;
cell.detailTextLabel.text = info.title;
return cell;
的tableView
(「常規」的一個)和searchResultsTableView
被設定內部viewDidLoad
如下:
//Set the default tableView style
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.opaque = NO;
self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
//Set the self.searchDisplayController background stuff
self.searchDisplayController.searchResultsTableView.backgroundColor = [UIColor clearColor];
self.searchDisplayController.searchResultsTableView.opaque = NO;
self.searchDisplayController.searchResultsTableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
[self.searchDisplayController.searchResultsTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.tableView reloadData];