uisearchdisplaycontroller によってフィルター処理された UITableView のセルの内容が表示されないのはなぜですか。実際には、検索バーで検索を実行すると、セルは正しくデコードされます (実際、検索によって並べ替えられたセルの数は正確です) が、cellForRowAtIndexPath でセルの内容を構成しても表示されません (画像とテキスト)。さらに、検索されたセルの 1 つをクリックすると、prepareForSegue の正確な方法で、対応する viewController への遷移が実行されます。問題は、セルにテキストと画像が表示されないことです。
配列構成 (配列 searchResults) が正しいことを考慮して、メソッド cellForRowAtIndexPath を示します。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = @"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
cell.backgroundView = [[UIImageView alloc] initWithImage:myImage];
if ( cell == nil ) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
if (tableView == self.searchDisplayController.searchResultsTableView) {
UIImage *profileSnap = myProfImage;
NSString *name = [searchResults objectAtIndex:indexPath.row];
UILabel *cellLabelName = (UILabel *)[cell viewWithTag:1];
cellLabelName.text = name;
UIImageView *cellImage = (UIImageView*)[cell viewWithTag:2];
[cellImage setImage:profileSnap];
}
else{
//here it all works
UIImage *profileSnap = [self.arrProfileSnaps objectAtIndex:indexPath.row];
NSString *name = [self.arrNames objectAtIndex:indexPath.row];
UILabel *cellLabelName = (UILabel *)[cell viewWithTag:1];
cellLabelName.text = name;
UIImageView *cellImage = (UIImageView*)[cell viewWithTag:2];
[cellImage setImage:profileSnap];
}
return cell;