0

从 UISearchBar 检索搜索结果后,结果正确显示在我的 tableview 中,但视图“变灰”(见下图)..对此的任何帮助表示赞赏,我在 Apple 文档中找不到解决方案。

这是我在点击搜索按钮时触发的代码:

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
isSearchOn = YES;
canSelectRow = YES;
self.tableView.scrollEnabled = YES;

CityLookup *cityLookup = [[CityLookup alloc] findCity:searchBar.text];

if ([cityLookup.citiesList count] > 0) {
    tableCities = cityLookup.citiesList;
}

[cityLookup release];

isSearchOn = NO;

self.searchBar.text=@"";

[self.searchBar setShowsCancelButton:NO animated:YES];
[self.searchBar resignFirstResponder];
[self.navigationController setNavigationBarHidden:NO animated:YES];

    [self.tableView reloadData];

}

这就是刷新表格视图的方式:

-(UITableViewCell *)tableView:(UITableView *)tableView
    cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *kCellID = @"cellID";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellID];
if (cell == nil)
{
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellID] autorelease];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}

NSString *cellValue = [tableCities objectAtIndex:indexPath.row];



cell.textLabel.text = cellValue;
    return cell;
}

替代文字

4

2 回答 2

0

您在点击搜索时没有隐藏搜索栏,请尝试:

[self.navigationController setNavigationBarHidden:YES animated:YES];
于 2010-11-26T17:48:03.153 回答
0

如果您使用带有UISearchDisplayController以下行的完整包,则应删除搜索界面:

[self.searchDisplayController setActive:NO animated:YES];

如果您不使用,UISearchDisplayController我建议您检查一下,看看它是否不适合您的需求。

备注:您发布的代码中没有任何内容可以删除您用来使表格视图变灰的任何视图。因此,如果您没有使用UISearchDisplayController,请查看显示搜索界面的代码,看看您需要做什么才能将其删除。

于 2010-11-27T17:19:26.167 回答