メインのtableViewには、いくつかのカスタムセル(基本的にはimageViewを持つセル)があります。
imageViewは、plistの値がfalseの場合にのみ設定されます。次に、それがtrueの場合、imageViewはnilです。
基本的に、ユーザーがdetailViewに入ると、値はに設定されYES
、cell.imageView
はnilになります。
そしてそれは大丈夫です、それは機能します
を使用しsearchDisplayController
ています。cell.imageViewを持つものを検索し、detailViewに移動してから戻るとsearchResultsTable
、セルにはまだ画像がありますが、そうではないはずですが、メインのtableViewには正しいセルがあります。 (つまり、画像なし)。
searchResultsTableViewに依存する可能性があると思いましたが、よくわかりません。で試してみました
[self.searchDisplayController.searchResultsTableView reloadData];
効果はありません。
searchResultsTableViewをリロードして、正しいセル、画像のあるセル、画像のないセルを表示するにはどうすればよいですか?
助けていただければ幸いです。
編集
これが私のcellForRowAtIndexPath
方法です:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSArray *rows;
if (tableView == self.searchDisplayController.searchResultsTableView) {
rows = filteredList; //for search
} else {
NSDictionary *section = [localSortedTips objectAtIndex:indexPath.section];
rows = [section objectForKey:@"Rows"];
}
NSDictionary *item = [rows objectAtIndex:indexPath.row];
cell.textLabel.text = [item objectForKey:@"name"];
if ([[item valueForKey:@"isRead"] boolValue] == NO) {
cell.imageView.image = [UIImage imageNamed:@"unread.png"];
} else {
cell.imageView.image = nil;
}
cell.textLabel.font = [UIFont boldSystemFontOfSize:15.0];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
return cell;
}