搜索后,UISearchbar更改结果

时间:2013-09-18 07:36:16

标签: iphone ios xcode uisearchbar

我在tableview中实现了搜索栏但是在搜索后我的地址从实际地址改变了,我现在应该怎么做

-(void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)text
{

    if(text.length == 0)
    {
        isFiltered = FALSE;
    }
    else
    {
        isFiltered = true;
        filteredListResults = [[NSMutableArray alloc] init];
        GWTG *gwtg ;
        for (gwtg in listResults)
        {
            NSRange nameRange = [gwtg.celebrity_name rangeOfString:text options:NSCaseInsensitiveSearch];//NSCaseInsensitiveSearch
            NSRange descriptionRange = [gwtg.location_name rangeOfString:text options:NSCaseInsensitiveSearch];
            if(nameRange.location != NSNotFound || descriptionRange.location != NSNotFound)
            {
                [filteredListResults addObject:gwtg];
            }
        }
    }

    [tblSearch reloadData];
}

0 个答案:

没有答案