我在这里想到了,在我的Core Data数据库中,我有很多用户,我通过NSFetchedResultController将数据库连接到tableviewcontroller,当视图加载时,我看到所有用户,并且我可以通过storyboard segue执行一个详细视图控制器的推...迄今为止,上帝,我的tableview包含一个图像视图的自定义单元格和2个uitextlabels,所有都有他们的标签值分配..UISearchDisplayController - 为什么我的搜索结果视图包含空单元格?
现在,当我执行搜索我用一个谓词创建一个新的NSFetchedResultController,并执行performFetch ..然后我得到了fetchedObjects属性,它包含匹配的用户,所以搜索请求也像魅力一样工作..在我所有的tableviews数据源中检查是否self.tableView == self.searchdispl.view查看哪些控制器我应该查询数据..在所有co ntrollers代表我查看哪个控制器是活动的,所以我知道要重新加载哪个视图。如果我记录了大量的数据,它在后台都很好,代理和数据源方法都使用正确的视图和fetchcontroller ..
在我的cellForRowAtIndexPath我可以注销我的user.name,并且始终是正确的,也在搜索时。
问题是,顶部的UISearchDisplayController视图只有空单元格,除非我将我的UITableViewControllers动态原型单元格设置为基本,然后这两个tableviews都包含带有用户名称的标签!细胞中的细胞仍不起作用,但细胞中有数据。
这似乎为UISearchDisplayControllers视图是一个通用的观点,至少当它涉及到塞格斯和单元布局...
我检查了我的UITableViewController从UISearchDisplayController所有的连接,所有看起来很好。 ..
为什么SearchDisplayControllers视图不接受我的单元布局和segue?
谢谢:)
更新:刚刚想通了什么错误,但没有找到解决办法。 在我cellForRowAtIndexPath单元格总是配置为默认单元格,当thr searchdisplayview是在这种方法..我真的需要在代码中创建我的单元格为uisearchdisplay工作?为什么它不能使用故事板中配置的单元?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"PersonCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSLog(@"Default Cell");
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSFetchedResultsController *controller = tableView == self.tableView ? self.fetchedResultsController : self.fetchedResultsControllerForSearch;
Person *p;
p = [controller objectAtIndexPath:indexPath];
[(UILabel*) [cell viewWithTag:1] setText:p.name];
[(UILabel*) [cell viewWithTag:2] setText:@"Status"];
if(p.avatarImage){
UIImage *avatar = [[UIImage alloc] initWithData:p.avatarImage];
[(UIImageView *) [cell viewWithTag:3] setImage:avatar];
}
return cell;
}
好吧,我只是让这个坐在这里,即使我只是想出了什么是错的,我有点尴尬,但也许这篇文章可以帮助别人:)问题是,当我得到在cellforrowatindexpath中的单元格,它没有从原始viewcontrollers tableview中获取它,所以我改变了从UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];到UITableViewCell * cell = [self。tableView dequeueReusableCellWithIdentifier:CellIdentifier];现在一切都很好,单元格有故事板和插件的布局,就像一个魅力:) – 2012-02-29 11:38:33
这真的起作用了,你应该发布这个作为你自己问题的答案! – 2013-12-06 11:04:40