解决方案 »

  1.   

    我写的,不怎么好使,希望给你点启示。
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *cellId=@"cellid";
        UILabel* label = nil;
        UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellId];
        if (cell==nil) {
            cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]autorelease];
            label = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 100, 30)];
            label.tag = 999;
            label.backgroundColor = [UIColor redColor];
            label.hidden = YES;
            [self.view addSubview:label];
        }else{
            flage = !flage;
            UILabel* label = (UILabel*)[self.view viewWithTag:999];
            
            if (flage) {
                label.hidden = NO;
            }else{
                label.hidden = YES;
            }    }
        
      
        //cell.textLabel.text=[self.listData objectAtIndex:[indexPath row]];
        
        return cell;
        
      

  2.   

    将UISearchBar 当作UITableView的headerView添加到UITableView中去
      

  3.   


        _searchBar = [[PBSearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44.0f)];
        _searchBar.placeholder = NSLocalizedString(@"Please enter route name", @"请点击输入线路名称");
        _searchBar.delegate = self;
        [self.view addSubview:_searchBar];
        
        _tableView = [[PBListTableView alloc] initWithFrame:CGRectMake(0, 50, self.view.bounds.size.width, self.view.bounds.size.height - 50.0)];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableHeaderView = _searchBar;
        [self.view addSubview:_tableView];
    把UITableView的tableHeaderView设置成UISearchBar的实例就行了。
      

  4.   

    https://github.com/fabiankr/TableViewSearchBar