- (void)viewDidLoad {
[super viewDidLoad];
searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 160, 44)];
searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
searchDisplayController.delegate = self;
searchDisplayController.searchResultsDataSource = self;
self.tableView.tableHeaderView = searchBar;
[searchDisplayController setSearchResultsDataSource: self];
[searchDisplayController setSearchResultsDelegate: self];![enter image description here][2]
// Do any additional setup after loading the view, typically from a nib.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)] autorelease];
self.navigationItem.rightBarButtonItem = addButton;
// inizializziamo l'oggetto Data
_objects = [[Data alloc] init];
filteredlist=[[NSMutableArray alloc]initWithArray:_objects.lista ];
}
在这个方法中,我添加了打开详细视图
[searchDisplayController setSearchResultsDataSource: self];
[searchDisplayController setSearchResultsDelegate: self];
唯一的问题是它打开了该单元格的视图,我需要在最初加载的列表中打开与该名称关联的详细视图。
问题是我搜索的时候打开对应的detail view
当我进行搜索时,我必须在单击名称时打开详细视图。