gpt4 book ai didi

ios - 在 UISearchDisplayController 中选择单元格后滚动到 UITableView 中的选定单元格?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:11:18 25 4
gpt4 key购买 nike

我想设置一个 UISearchDisplayController,以便在从搜索结果中选择一个单元格后,搜索显示 Controller 被关闭并且表格 View 滚动到所选单元格。这是我的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == self.searchDisplayController.searchResultsTableView)
{
[self.searchDisplayController setActive:NO];

// scroll to selected cell in table view here
}
}

我知道我需要使用的方法是:

scrollToRowAtIndexPath:atScrollPosition:animated:

但是,此方法需要来自主 TableView 的索引路径,而不是搜索结果 TableView 。我怎样才能得到这个索引路径?

最佳答案

您的数据源是什么样的?也许您可以根据在搜索结果中选择的内容来查询数据源以获得单元格的索引。

听起来像是一种奇怪的用户交互,但不知道您在做什么。通常搜索然后选择会将您带到该记录的详细信息或将其选择为选项或其他内容。

关于ios - 在 UISearchDisplayController 中选择单元格后滚动到 UITableView 中的选定单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18554411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com