-1

我有一個目錄,並在頂部有一個搜索欄,但是,當我在表格內容中搜索特定名稱時,它不會顯示在表格視圖中,但是,我有「NSLog」這是打印我的搜索結果。搜索結果正確但不顯示在表格視圖中; 這裏是使用搜索欄不顯示正確的結果

+0

我發現,您使用的是謂詞過濾結果,但沒發現你在哪裏重新綁定你的UISearchDisplayController的您的過濾結果的任何代碼表視圖。 –

回答

0

檢查這些方法實現功能時

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
if (tableView==self.mySearchDisplayController.searchResultsTableView) { 

    return [_filteArray count]; 
} 
else{ 

    return [_myArray count]; 
} 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *[email protected]"Cell"; 
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier]; 
if (cell==nil) { 

    cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier]; 
} 

if (tableView == self.mySearchDisplayController.searchResultsTableView) { 

    placeObject=(GCSearchObject*)[_filterArray objectAtIndex:indexPath.row]; 
    cell.textLabel.text=placeObject.serviceName; 

} else { 
    placeObject=(GCSearchObject*)[_myArray objectAtIndex:indexPath.row]; 
    cell.textLabel.text=placeObject.serviceName; 
} 
return cell; 
}