1

I have a uisearchbar that does a search successfully. The problem is that the searchResultsTableView doesn't show the results because it is using a regular UITableViewCell instead of my custom cell. I have set this custom cell in storyboards and connected the outlets to make sure everything is working properly.

My cellForRowAtIndexPath method looks like this:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"InviteCell"; InviteTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if ( cell == nil ) { cell = [[InviteTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } MyUser *person = nil; if (tableView == self.searchDisplayController.searchResultsTableView) { person = [self.filteredContactArray objectAtIndex:[indexPath row]]; //This works and shows cell.detailTextLabel.text = @"testing if using default cell"; } else { person = [self.inviteContactsArray objectAtIndex:[indexPath row]]; } //InviteTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; person = [self.inviteContactsArray objectAtIndex:indexPath.row]; //these do not work and do not show in the results view cell.nameLabel.text = person.fullName; cell.emailLabel.text = person.email; return cell; } 

This is what the results view looks like:

enter image description here

1

1 Answer 1

2

Currently there is no way for a prototype cell created in a storyboard to be registered in the searchResultsTableView.

A workaround is to put the cell into a separate xib file and register it for both the self.tableView and the self.searchDisplayController.searchResultsTableView using -[UITableView registerNib:forCellReuseIdentifier:].

For further information about this method see the documentation of UITableView.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.