0

searchResultsTableView「通常の」非検索テーブルビューのセルと同じように見えるように、セル内で返されるセルを取得しようとしています。これが私の通常のビューです。

初めて検索すると、結果は「通常の」テーブル ビューとまったく同じようにスタイル設定されます。ただし、searchDisplayController をキャンセルしてもう一度 [検索] ボタンをタップすると、この が表示されます

検索ディスプレイコントローラーが初めて読み込まれた後、背景が設定されていないように見えます。

カスタム サブクラスではなく、tableView:cellForRowAtIndexPath:を使用してセルをインスタンス化しています。UITableViewCellメソッドの残りの部分は次のとおりです。

PersonInfo *info = nil;
if (tableView == self.searchDisplayController.searchResultsTableView) {
    info = [self.filteredPeopleList objectAtIndex:indexPath.row];
} else {
    info = [self.peopleList objectAtIndex:indexPath.row];
}

cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellBk.png"]];
cell.detailTextLabel.textColor = [UIColor whiteColor];
cell.backgroundColor = [UIColor clearColor];

cell.imageView.image = info.image;
cell.textLabel.text = info.name;
cell.detailTextLabel.text = info.title;

return cell;

tableView「通常の」もの)とsearchResultsTableView内部で次のように設定されていますviewDidLoad

//Set the default tableView style
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.opaque = NO;
self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

//Set the self.searchDisplayController background stuff
self.searchDisplayController.searchResultsTableView.backgroundColor = [UIColor clearColor];
self.searchDisplayController.searchResultsTableView.opaque = NO;
self.searchDisplayController.searchResultsTableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
[self.searchDisplayController.searchResultsTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

[self.tableView reloadData];
4

1 に答える 1

0

UISearchDisplayDelegateのメソッドであるにスタイルを設定するコードを移動すると、これが処理searchResultsTableViewされます。searchDisplayController:willShowSearchResultsTableView:

于 2013-03-13T15:54:36.850 に答える