2

嗨,我有几个 UITableViews。我想为每个表格添加搜索栏。

所以我添加了 UISearchbars 两个表。

我只加了searchbars,没加UISearchbarDisplaycontroller

当用户在搜索栏上输入内容并按下键盘上的搜索按钮时,搜索结果会到达另一个NSMutableArray并分配给我的原始数组。然后重新加载UITableView

根据我的代码它的工作。当我输入内容并按下搜索按钮时,我的表格会重新加载新数据。但现在的问题是我无法单击任何单元格。似乎它没有调用didselectRowatIndex方法。但是单元格内的按钮仍然可以正确单击。只有单元格单击事件没有调用。

这应该是什么原因。请帮我

谢谢

编辑

.h
@interface HomeViewController : UIViewController<UITabBarDelegate,UITableViewDataSource,UITableViewDelegate,FPPopoverControllerDelegate,AVAudioPlayerDelegate,UISearchBarDelegate>

ViewDidload

searchbarAllusers.delegate=self;
searchbarAllusers.showsCancelButton = YES;
searchbarArtists.delegate=self;
searchbarArtists.showsCancelButton=YES;

Search delegates

-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar3
{
    if (searchBar3.text.length==0) {
        isSearch=NO;
    }
    else
    {
        isSearch=YES;
        if (searchBar3.tag==1) {
            [self filterListForSearchText:searchBar3.text :@"USR"];
        }

        else if (searchBar3.tag==2)
        {
            [self filterListForSearchText:searchBar3.text :@"ARTIST"];
        }

        [searchBar3 resignFirstResponder];
    }
}

-(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar2
{
    [searchBar2 resignFirstResponder];
    isSearch=NO;

    if (searchBar2.tag==1) 
    {
            tblAddFriends.delegate=self;
            searchbarAllusers.delegate=self;
            tblAddFriends.allowsSelection=YES;
        [tblAddFriends reloadData];
    }
    else if (searchBar2.tag==2)
    {
        arrArtistList=artistTemparray;
        tblArtists.delegate=self;
        searchbarArtists.delegate=self;
        tblArtists.allowsSelection=YES;
        [tblArtists reloadData];
    }   
}  
- (void)filterListForSearchText:(NSString *)searchText : (NSString *)status
{
    [searchResult removeAllObjects];
    if([status isEqualToString:@"USR"])
    {
        searchResult=[ws SearchItems:searchText :status];
        [tblAddFriends reloadData];
    }
    else if([status isEqualToString:@"ARTIST"])
    {
        searchResult=[ws SearchItems:searchText :status];
        [tblArtists reloadData];
    }
}
4

0 回答 0