0

我有一个带有 SearchBar 的 tableview 和它的委托方法。我需要能够显示在搜索结果中使用搜索词后获得的 SQL 查询的结果,而不是搜索 tableview 本身。

获取 SQL 查询结果不是问题。

我只需要知道如何使用查询中的文本直接填充搜索结果单元格。

我发现的所有示例似乎都处理使用与搜索词匹配的数据过滤原始表格视图,因此它们对我的情况没有帮助。

有人可以提供一个示例或代码,我可以将其放入 searchBarTextDidEndEditing 委托中,例如用数组中的数据填充搜索结果。

我试过做这样的事情,但它显然不起作用,我仍在努力学习 IOS 编程,所以我没有任何使用 searchBars 的经验,可能在这里的左边字段......

- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
    NSLog(@"search bar did end text editing %@", searchBar.text);
    _searchResultsCellData = [[NSMutableArray alloc] init];
    NSMutableArray *searchCells = [[NSMutableArray alloc] init];

    NSDictionary *cellSearchContainer = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"TEST", @"location", @"", @"", @"", @"2", nil]
                                                                forKeys:[NSArray arrayWithObjects:@"Text", @"Detail Text", @"Image", @"Text Color", @"Detail Text Color", @"Accessory", nil]];
    [searchCells addObject:cellSearchContainer];

    [_searchResultsCellData addObject:searchCells];

    static NSString *CellIdentifier = @"parentCells";

    UITableViewCell *cell = [_parentsTable dequeueReusableCellWithIdentifier:CellIdentifier];

    cell.textLabel.text = @"test";

}
4

0 回答 0