代码之家  ›  专栏  ›  技术社区  ›  squeezemylime

在用内容重新加载我的tableView之后,在我点击它之前它仍然显示为灰色..为什么?

  •  0
  • squeezemylime  · 技术社区  · 14 年前

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

    alt text

    2 回复  |  直到 14 年前
        1
  •  0
  •   Robert Höglund    14 年前

    如果您使用的是 UISearchDisplayController 以下行应删除搜索界面:

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

    如果你不使用 uisearchdisplay控制器 我建议你去看看是否不适合你的需要。

    备注:在你发布的代码中,没有任何东西可以删除你用来灰显表视图的任何视图。所以如果你不使用 uisearchdisplay控制器 在显示搜索界面的代码中查看要删除它需要执行的操作。

        2
  •  0
  •   WrightsCS    14 年前

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

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