ios – 如何从UISearchBarDisplayController结果转换为detailViewController

ios – 如何从UISearchBarDisplayController结果转换为detailViewController,第1张

概述因此,使用storyboard,您可以从UITableViewCell创建一个segue,从第一个tableViewController到detailViewController. 但是,当故事板混合中引入UISearchBarDisplayController时,不是太复杂,如何将结果单元格转换为detailViewController? 我能够毫无问题地进行搜索,我遵循了本教程:http:// 因此,使用storyboard,您可以从UItableVIEwCell创建一个segue,从第一个tableVIEwController到detailVIEwController.

但是,当故事板混合中引入UISearchbardisplayController时,不是太复杂,如何将结果单元格转换为detailVIEwController?

我能够毫无问题地进行搜索,我遵循了本教程:http://clingingtoideas.blogspot.com/2010/02/uitableview-how-to-part-2-search.html

我所能做的就是从搜索中选择一行,它变为蓝色,不会转到detailVIEwController.

我已经实现了prepareForSegue方法,该方法适用于未搜索的单元格,但无法弄清楚这一点.

解决方法 这是基于@James Chen评论的解决方案.还使用不同的IndexPath,具体取决于表所处的状态.

- (voID)prepareForSegue:(UIStoryboardSegue *)segue sender:(ID)sender{    if ([[segue IDentifIEr] isEqualToString:@"toDetail"]) {        Person *person = nil;        if (self.searchdisplayController.active == YES) {            NSIndexPath *indexPath = indexPath = [self.searchdisplayController.searchResultstableVIEw indexPathForSelectedRow];            NSLog(@"segue - section: %d,row: %d",indexPath.section,indexPath.row);            person = [self.filteredPersonArray objectAtIndex:indexPath.row];        }        else {            NSIndexPath *indexPath = indexPath = [self.tableVIEw indexPathForSelectedRow];            NSLog(@"segue - section: %d,indexPath.row);            person = [self.personArray objectAtIndex:indexPath.row];        }        [[segue destinationVIEwController] setPerson:person];       }}
总结

以上是内存溢出为你收集整理的ios – 如何从UISearchBarDisplayController结果转换为detailViewController全部内容,希望文章能够帮你解决ios – 如何从UISearchBarDisplayController结果转换为detailViewController所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1071276.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存