Objective c 它没有';t在UITableView中显示由UISearchDisplayController筛选的单元格内容
为什么不在uisearchdisplaycontroller筛选的UITableView中显示单元格的内容。 实际上,当我在搜索栏中执行搜索时,单元格被正确解码(事实上,按搜索排序的单元格数量是准确的),但在cellForRowAtIndexPath中配置它们时,单元格内容也不会显示(图像和文本)。 此外,如果单击搜索的单元格之一,prepareForSegue中的确切方式将执行到相应viewController的转换。 所以问题是它不能在我的手机中显示文本和图像 考虑到阵列配置(阵列搜索结果)是正确的,我向您展示了我的方法CellForRowatineXpath:Objective c 它没有';t在UITableView中显示由UISearchDisplayController筛选的单元格内容,objective-c,uitableview,uisearchbar,uisearchdisplaycontroller,Objective C,Uitableview,Uisearchbar,Uisearchdisplaycontroller,为什么不在uisearchdisplaycontroller筛选的UITableView中显示单元格的内容。 实际上,当我在搜索栏中执行搜索时,单元格被正确解码(事实上,按搜索排序的单元格数量是准确的),但在cellForRowAtIndexPath中配置它们时,单元格内容也不会显示(图像和文本)。 此外,如果单击搜索的单元格之一,prepareForSegue中的确切方式将执行到相应viewController的转换。 所以问题是它不能在我的手机中显示文本和图像 考虑到阵列配置(阵列搜索结果)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = @"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
cell.backgroundView = [[UIImageView alloc] initWithImage:myImage];
if ( cell == nil ) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
if (tableView == self.searchDisplayController.searchResultsTableView) {
UIImage *profileSnap = myProfImage;
NSString *name = [searchResults objectAtIndex:indexPath.row];
UILabel *cellLabelName = (UILabel *)[cell viewWithTag:1];
cellLabelName.text = name;
UIImageView *cellImage = (UIImageView*)[cell viewWithTag:2];
[cellImage setImage:profileSnap];
}
else{
//here it all works
UIImage *profileSnap = [self.arrProfileSnaps objectAtIndex:indexPath.row];
NSString *name = [self.arrNames objectAtIndex:indexPath.row];
UILabel *cellLabelName = (UILabel *)[cell viewWithTag:1];
cellLabelName.text = name;
UIImageView *cellImage = (UIImageView*)[cell viewWithTag:2];
[cellImage setImage:profileSnap];
}
return cell;
您在哪里填充搜索结果?您是否验证了它是否为您的变量名分配了正确的值
NSString*name=[searchResults objectAtIndex:indexPath.row]代码>显示填充searchResults数组的代码。searchResults已正确填充,我已签入调试并使用NSLog。问题就在这里