为什么在ios中过滤数据后,在表视图中搜索会显示空白表视图?

为什么在ios中过滤数据后,在表视图中搜索会显示空白表视图?,ios,objective-c,uitableview,Ios,Objective C,Uitableview,当我在表视图中搜索时,它给出了正确的数组,我正在使用NSPredicate过滤数组。即使在调试时,我知道,它会转到cellforrowatinexpath,标签上有数据,一切正常,但结果显示的是纯白色的默认表视图,而不是搜索后应该显示的表 这是我的密码: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *C

当我在表视图中搜索时,它给出了正确的数组,我正在使用
NSPredicate
过滤数组。即使在调试时,我知道,它会转到
cellforrowatinexpath
,标签上有数据,一切正常,但结果显示的是纯白色的默认表视图,而不是搜索后应该显示的表

这是我的密码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
preferredCustomCell *mycell = (preferredCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

UIView *backgroundView = [[UIView alloc] initWithFrame:mycell.selectedBackgroundView.frame];
[backgroundView setBackgroundColor:[UIColor colorWithRed:189/255.f green:189/255.f blue:189/255.f alpha:0.25]];
[mycell setSelectedBackgroundView:backgroundView];
SearchbackView.hidden = YES;

// Configure the cell...
if (mycell == nil) {
    mycell = [[preferredCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

MyData *dealerData = Nil;
if (tableView == self.searchDisplayController.searchResultsTableView) {
    dealerData = [searchResults objectAtIndex:indexPath.row];
} else {
    dealerData = [cellData objectAtIndex:indexPath.row];
}

dealerInfo = [NSString stringWithFormat:@"%@\n%@\n%@%@%@%@%@\n%@\n%@", dealerData.businessName, dealerData.address, dealerData.city,@", ", dealerData.state, @", ", dealerData.zip, dealerData.phone, dealerData.email];  // data.address;

mycell.dealerInfoLbl.text = dealerInfo;
mycell.dealerInfoLbl.numberOfLines = 0;

mycell.selectDealerBtn.tag = indexPath.row;

// Assign our own background image for the cell
UIImage *background = [UIImage imageNamed:@"selectedCell"];
UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:background];
cellBackgroundView.image = background;
mycell.selectedBackgroundView = cellBackgroundView;
mycell.lblPreferred.hidden = YES;

if (mycell.selectDealerBtn.tag==btnTag) {
    if (selectDealer==true) {
        [mycell.selectDealerBtn setImage:[UIImage imageNamed:@"selectedDealer"] forState:UIControlStateNormal];
        [mycell.selectDealerBtn setTitle:@"Select" forState:UIControlStateNormal];
        mycell.selectDealerBtn.imageEdgeInsets = UIEdgeInsetsMake(6, 16, 26, 17);
        mycell.selectDealerBtn.titleEdgeInsets = UIEdgeInsetsMake(32,-66, 0, 10);
        mycell.lblPreferred.hidden = NO;
    }
}
else{
    [mycell.selectDealerBtn setImage:[UIImage imageNamed:@"N99-selectDealerBtn"] forState:UIControlStateNormal];
    [mycell.selectDealerBtn setTitle:@"   " forState:UIControlStateNormal];
    mycell.lblPreferred.hidden = YES;
}

return mycell;

您确定您的searchedData数组已填充吗?您确定数组是alloc'd/init'd吗?在将搜索数组提供给单元格之前,请尝试记录搜索数组。那么你可以看到那是不是装满了?@TotumusMaximus,是的。我敢肯定。searchedData数组已填充。@如您所愿,是的。我试过了。数组已填充。@Aadhya是否正确设置了代理??