从搜索显示控制器的表视图推送详细信息控制器
我在我的应用程序中实现了搜索选项,但是当我搜索某些内容时,我无法从搜索显示控制器的表视图中推送详细信息控制器。
有办法做到这一点吗?
太感谢了!
I implemented a search option in my app but when I search something, I can't push a detail controller from the search display controller's table view.
Is there a way to do that?
Thank you so much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们假设您在
UIViewController
中有一个名为 SearchViewController 的UISearchBarDelegate
方法。要推送(DetailViewController*) dvc
,请在 SearchViewController 中实现以下方法:UIDetailViewController
声明一个带有“did”的协议 finish”方法和您喜欢的任何类型的属性,既可以从 SearchViewController 接收数据,也可以在任何详细处理后发回任何数据。通过将控件从UISearchViewController
拖动到UIDetailViewController
,可以在 Xcode IB 中添加 Segue。 注意: Segue 源和目标是视图控制器本身。这样,它们就可以以编程方式调用,而不是在点击事件上自动调用。We'll assume you have a
UISearchBarDelegate
method in aUIViewController
called SearchViewController. To push(DetailViewController*) dvc
, implement these methods in SearchViewController:UIDetailViewController
declares a protocol with the "did finish" method and properties of whatever type you like, both to receive data from SearchViewController and to send back any data after any detail processing. The segue is added in Xcode IB by control dragging fromUISearchViewController
toUIDetailViewController
. NB: the segue source and destination are the view controllers themselves. That way they can be invoked programmatically as opposed to automatic invocation on a tap event.