UISearchDisplayController não exibindo corretamente células personalizadas
Então eu tenho um tableView que tem seções e linhas, e ele usa uma classe de célula personalizada. A célula personalizada tem uma visualização de imagem e alguns rótulos. A exibição de tabela funciona bem e a pesquisa funciona, exceto que a pesquisa não exibe nenhuma das etiquetas que estão na minha classe de célula personalizada, somente a imageView com a imagem correta. Estou muito confuso sobre o porquê disso, especialmente porque a imagem ainda é exibida, mas não os rótulos. Aqui está algum código.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//TODO: problem with search view controller not displaying labels for the cell, needs fixing
JSBookCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if(cell == nil) {
cell = [[JSBookCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
JSBook *book = nil;
//uses the appropriate array to pull the data from if a search has been performed
if(tableView == self.searchDisplayController.searchResultsTableView) {
book = self.filteredTableData[(NSUInteger)indexPath.section][(NSUInteger)indexPath.row];
}
else {
book = self.books[(NSUInteger)indexPath.section][(NSUInteger)indexPath.row];
}
FFMetaData *data = [self.ff metaDataForObj:book];
cell.titleLabel.text = book.title;
cell.priceLabel.text = [NSString stringWithFormat:@"$%@", book.price];
cell.authorLabel.text = book.author;
cell.descriptionLabel.text = book.description;
cell.dateLabel.text = [self.formatter stringFromDate:data.createdAt];
if(book.thumbnail == nil) {
cell.imageView.image = [UIImage imageNamed:@"messages.png"];
[self setCellImage:cell withBook:book atIndex:indexPath withTableView:tableView];
}
else {
cell.imageView.image = [UIImage imageWithData:book.thumbnail];
}
return cell;
}
Antes desse problema, eu tinha apenas uma seção no tableView e tudo funcionava perfeitamente. Agora que tenho várias seções e linhas, a pesquisa é interrompida conforme descrevi. Alguma ideia? Também para[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
eu costumava ter[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Mas agora, se eu usar, recebo uma exceção estranha quando tento pesquisar:
NSInternalInconsistencyException ', razão:' pedido para rect no caminho do índice inválido (2 índices [1, 1]) '
Então isso está me confundindo também. Obrigado pela ajuda!