I want to load the search display controller's table view with all the data in the data source before the user begins the search.
I used
[self.searchDisplayController.searchResultsTableView reloadData];
in viewDidLoad but the UITableViewDataSource delegate method
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
does not get called. My table stays empty. I manually filled the data source before reloading the table view (and verified this in debug mode), so there is data to populate cells with.
I know I can do this using another table view and achieve exactly same results visually but I want to know if only the search display controller's table view can be used.
Code:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
static NSString *cellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
NSString *category = [searchResults objectAtIndex:[indexPath row]];
cell.textLabel.text = category;
cell.textLabel.font = [UIFont systemFontOfSize:14];
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
return cell;
}