我在表视图中有一个UITableView
withsearchDisplayController
和一个按钮作为 contentView。
我在表格视图中显示一个带有字典的数组。当我使用 searchBar 搜索时,我从数组中获取了一个搜索项。
现在我想要的是,当我使用 searchBar 搜索时,我想在按钮操作上获取该对象。
按钮操作代码
-(void)getClickObject:(UIButton *)sender
{
UITableViewCell *cell = (UITableViewCell *)sender.superview.superview;
NSIndexPath *path = [listOfProductsTable indexPathForCell:cell];
}
在上述方法中,我在表视图中获取索引对象
-(void) filterForSearchText:(NSString *) text scope:(NSString *) scope
{
[searchResultArry removeAllObjects];
NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"SELF.name contains[c] %@",text];
searchResultArry = [NSMutableArray arrayWithArray:[nameArry filteredArrayUsingPredicate:filterPredicate]];
}
-(BOOL) searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[self filterForSearchText:searchString scope:[[[[self searchDisplayController] searchBar] scopeButtonTitles] objectAtIndex:[[[self searchDisplayController] searchBar] selectedScopeButtonIndex] ]];
return YES;
}
-(BOOL) searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption
{
[self filterForSearchText:self.searchDisplayController.searchBar.text scope:
[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:searchOption]];
return YES;
}
在表格视图中搜索时,我想在按钮操作上获取单元格对象