我应该如何从搜索结果导航到详细视图?

发布于 2024-10-17 04:44:55 字数 776 浏览 4 评论 0原文

该应用程序的工作方式非常标准。我有一个主表视图,其中的单元格包含图像和文本。当我点击一个项目时,我会进入由 UIWebView 组成的相应详细视图。可以查表。当我搜索表格时,结果显示正确。但是,当我点击搜索结果中的某个项目时,我不会进入正确的详细视图。相反,我会在搜索之前进入该行中存在的项目的详细视图。

我需要调整/添加什么才能在选择搜索结果时显示正确的详细视图?

抱歉没有发布代码;如果您需要特别查看某些内容,请告诉我。谢谢!

更新代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MObjectDetailVC *mObjectDetailVC = [[MObjectDetailVC alloc] initWithNibName:@"MObjectDetailVC" bundle:nil];
mObjectDetailVC.detailURL = [[NSURL alloc] initWithString:[[mcData objectAtIndex:indexPath.row] url]];
mObjectDetailVC.title = [[mcData objectAtIndex:indexPath.row] name];
[self.navigationController pushViewController:mObjectDetailVC animated:YES];
[mObjectDetailVC release];
}

The way the app works is pretty standard. I have a main table view with cells that contain an image and text. When I tap on an item, I am taken to a corresponding detail view made up of a UIWebView. The table can be searched. When I search the table, the results show up correctly. However, when I tap on an item from the search results, I am not taken to the correct detail view. Instead, I am taken to the detail view of the item that existed in that row before searching.

What do I need to adjust/add so that the correct detail view is displayed when a search result is selected?

Sorry for not posting code; if you need to see something in particular, just let me know. Thanks!

UPDATED WITH CODE:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MObjectDetailVC *mObjectDetailVC = [[MObjectDetailVC alloc] initWithNibName:@"MObjectDetailVC" bundle:nil];
mObjectDetailVC.detailURL = [[NSURL alloc] initWithString:[[mcData objectAtIndex:indexPath.row] url]];
mObjectDetailVC.title = [[mcData objectAtIndex:indexPath.row] name];
[self.navigationController pushViewController:mObjectDetailVC animated:YES];
[mObjectDetailVC release];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

煞人兵器 2024-10-24 04:44:55

获得搜索结果后,您应该重组数组。有两个数组:一个数组包含整个数据,一个 searchResultArray 包含搜索查询中的数据。如果您不进行搜索,请将 searchResultArray 保留为 NULL,并继续显示您当前基于原始数组所做的结果。但是,一旦搜索完成并获得一些结果,请将相同的结果填充到 searchResultArray 中。现在,当您单击特定行时,在 didSelectRow 方法中检查 searchArray 是否为空。如果它不为空,则使用此 searchResultArray 填充详细信息视图。

You should reform your array after you get the search results. Have two arrays: one array that contains the entire data and one searchResultArray that contains the data from the search query. If you are not searching keep the searchResultArray as NULL and keep showing the results as you are doing currently based on the original array. However as soon as a search is done and you get some results, populate the same in the searchResultArray. Now when you click a particular row, then in the didSelectRow method check if the searchArray is empty or not. If it is not empty then use this searchResultArray to populate the detail view.

蓦然回首 2024-10-24 04:44:55

可能您正在从旧数组中检索值。

检查您的代码是否从搜索数组中获取值。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   [searchArray objectAtIndex:indexPath.row];
}

May be you are retrieving the value from the old array.

Check your code that you are fetching the value from searched array.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   [searchArray objectAtIndex:indexPath.row];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文