UIsearch bar not returning data to table

Posted by Insane_Poyo on Stack Overflow See other posts from Stack Overflow or by Insane_Poyo
Published on 2012-06-29T07:20:44Z Indexed on 2012/07/02 9:16 UTC
Read the original article Hit count: 185

Filed under:
|
|
|

Edited code

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
   if (cell==nil) 
    cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];


if (isFiltered) {
   int rowCount=indexPath.row;
   Aves *filtrada=[filteredTableData objectAtIndex:rowCount];
   cell.textLabel.text=filtrada.name;
   NSLog(@"mostrando: ");
    }else {
        int rowCounter=indexPath.row;
        Aves *author=[theauthors objectAtIndex:rowCounter];
        cell.textLabel.text=author.name;
    }
NSLog(@"mostrando: ");
return cell;

}

-(void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)text
{
    if(text.length == 0)
    {
        isFiltered = FALSE;
    }
    else
    {
        isFiltered = true;
        int i;
        [filteredTableData removeAllObjects];
        for(i=0;[theauthors count]>i;i++)
        {
          Aves *name=[theauthors objectAtIndex:i];
            //NSLog(name.name);
            NSRange nameRange = [[name.name lowercaseString] rangeOfString:[text lowercaseString]];
            if(nameRange.length>0)
            {
                [filteredTableData addObject:name];
                NSLog(name.name);
            }
        }
        [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
    }
}

Edit: After working on it a while I solved some problems.Just updated my code, the problem is the repaint of the tableView, every thing else go ok. Check it and give any ideas you have plz ^^

Thx again for your time.

© Stack Overflow or respective owner

Related posts about ios

Related posts about xcode