无法从 UISearchDisplayController 委托推送视图控制器
我创建了一个 UISearchDisplayController,它使用单独的 UITableViewController 作为委托来显示搜索结果。在这个视图控制器中,我有“didSelectRowAtIndexPath”方法,该方法分配并初始化一个detailViewController,然后使用:
[[self navigationController] pushViewController: detailViewController animated: YES];
将其推入堆栈。然而,这条线不起作用。当点击一个单元格时,什么也不会发生。正在调用“didSelectRowAtIndexPath”,但“pushViewController”方法调用不起作用。我不再处于我的 navigationController 的上下文中了吗?我该如何解决这个问题?
任何帮助将不胜感激。
I have created a UISearchDisplayController which uses a separate UITableViewController as the delegate to display the results of the search. In this view controller, I have the 'didSelectRowAtIndexPath' method which allocates and initializes a detailViewController then uses:
[[self navigationController] pushViewController: detailViewController animated: YES];
to push it onto the stack. However, this line doesn't work. When a cell is tapped, nothing happens. 'didSelectRowAtIndexPath' is being called, but the 'pushViewController' method call isn't working. Am I not in the context of my navigationController any more? How can I fix this problem?
Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的表的navigationController可能是错误的,我认为你可能想将它推到你的UISearchDisplayController的navigationController上。
为此,您可以使用“pushViewController”方法在 tableviewcontroller 中创建一个协议,并让 UISearchDisplayController 实现它。
然后,您在表视图中注册此委托,并在“didSelectRowAtIndexPath”中调用 PushViewcontroller 上的委托
your table's navigationController is probably the wrong one, I think that you might want to push it on the navigationController of your UISearchDisplayController.
To do this, you can create a protocol in your tableviewcontroller with a method "pushViewController" for instance and have UISearchDisplayController implement it.
Then your register this delegate in your table view and you call your delegate on pushViewcontroller in your 'didSelectRowAtIndexPath'