iphone - UISearchDisplayController not correctly displaying custom cells -
so have tableview has sections , rows, , uses custom cell class. custom cell has image view , few labels. table view works fine, , search works, except search not display of labels in custom cell class, imageview correct image. quite confused why is, since image still displayed, not labels. here code.
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { //todo: problem search view controller not displaying labels cell, needs fixing jsbookcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; if(cell == nil) { cell = [[jsbookcell alloc]initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } jsbook *book = nil; //uses appropriate array pull data if 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;
}
before problem, had 1 section in tableview, , worked perfectly. have multiple sections , rows search broken described. ideas? also, [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];
used have [self.tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];
if use weird exception when try search:
nsinternalinconsistencyexception', reason: 'request rect @ invalid index path ( 2 indexes [1, 1])'
so confusing me also. help!
[self.tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];
did not work because table view cells registered specific table view. not work search results controller table view. did find out , switched to:
[tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];
which right thing do.
also, designing custom cell in storyboard not work search results controller because not able design cells search table view, main table view.
yes, can register class search table view, did here,
[self.searchdisplaycontroller.searchresultstableview registerclass:[jsbookcell class] forcellreuseidentifier:cellidentifier];
but not have of stuff designed in custom cell in storyboard. have create programmatically.
Comments
Post a Comment