如何在搜索后显示 DetailView
我使用谓词来过滤表。 它工作得很好,还可以显示每个单元格的详细视图。
但过滤后,无法在详细视图中显示过滤后的列表。 按下该单元格时它只会变成蓝色,但不会切换到详细视图。
我在这里缺少什么?
代码如下所示。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
Person *person;
if (tableView == self.searchDisplayController.searchResultsTableView)
{
person = [self.filteredPeople objectAtIndex:indexPath.row];
}
else
{
person = [self.people objectAtIndex:indexPath.row];
}
dvController.title = person.firstName;
dvController.price = person.sjuName;
dvController.link = person.sexName;
dvController.picture = [UIImage imageNamed:person.femName];
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
dvController = nil;
}
I use predicate to filter a table.
It works very well and also to display the detailView for each cell.
But after a filtering it does not work to display the filtered list in the detailView.
The cell just turns blue when pressing it but does not shift to detailView.
What am I missing here?
The code looks like this.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
Person *person;
if (tableView == self.searchDisplayController.searchResultsTableView)
{
person = [self.filteredPeople objectAtIndex:indexPath.row];
}
else
{
person = [self.people objectAtIndex:indexPath.row];
}
dvController.title = person.firstName;
dvController.price = person.sjuName;
dvController.link = person.sexName;
dvController.picture = [UIImage imageNamed:person.femName];
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
dvController = nil;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里两个 tableView 属于不同的类,因此不能相等,因此将 if 条件更改为
Here both the tableView are of different class so the can't be equal thus change your if condition as