【问题标题】:After reloading my tableView with content, it still appears greyed-out until I tap it..why?用内容重新加载我的 tableView 后,它仍然显示为灰色,直到我点击它..为什么?
【发布时间】:2010-11-26 17:27:32
【问题描述】:

从 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;
}

【问题讨论】:

    标签: iphone uitableview uisearchbar reloaddata


    【解决方案1】:

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

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

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

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

    【讨论】:

      【解决方案2】:

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

      [self.navigationController setNavigationBarHidden:YES animated:YES];
      

      【讨论】:

      • 只是隐藏导航栏,而不是 SearchBar..表格仍然有灰色背景..
      • 糟糕,然后尝试关闭搜索栏。
      • 我知道,这就是为什么它如此令人沮丧...我会尝试从头开始重写,看看我是否遗漏了什么
      猜你喜欢
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-06
      • 1970-01-01
      • 1970-01-01
      • 2017-03-10
      相关资源
      最近更新 更多