带有 Segue 的 UISearchbar (UISearchResultsUpdating) 不会关闭 [英] UISearchbar (UISearchResultsUpdating) with Segue does not dismiss
问题描述
我在使用 UISearchBar
时遇到问题.当我结合 UITableView
搜索一些文本,并单击一个结果单元格时,UISearchBar
在下一个 UIViewController
中仍然可见.UISearchbar
仍然存在(带有关键字)
I have a problem with a UISearchBar
. When I search some Text in combination with an UITableView
, and ill click on one result Cell, the UISearchBar
is still visible in the next UIViewController
. the UISearchbar
is still there (with the Keyword)
所以在点击一个结果后,我会得到(在下一个视图控制器中)但搜索栏和键盘仍在显示.
So after ill click on one result, ill get (in the next View Controller)but the searchbar and keyboard is still showing.
如何关闭当前的 UISearchController
以便搜索栏和键盘不显示在下一个 UIViewController
中?
how can i dismiss the current UISearchController
so that the search bar and keyboard do not show in the next UIViewController
?
我试过了:
definesPresentationContext = true
我试图关闭 presentingViewController
.
我正在为转场做所有这些准备.
Im doing all of this in the prepared for segue.
我的想法是我必须关闭 UISearchController
...但是我如何在 preparedForSegue
(在 searchResultsViewControllers
中)访问它 -这是一个 tableViewController
,用于呈现 searchResults
)
My thinking is that I have to dismiss the UISearchController
...but how can I access it in preparedForSegue
(in the searchResultsViewControllers
- this is a tableViewController
which is used to present the searchResults
)
推荐答案
你必须使用这样的东西,忘记definePresentationContext
You gotta use something like this, forget about the definesPresentationContext
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
searchController.active = false //This will dismiss the searchcontroller, use your own variable for searchController.
//CALL THE SEGUE YOU WANT BELOW
}
这篇关于带有 Segue 的 UISearchbar (UISearchResultsUpdating) 不会关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!