【发布时间】:2016-11-11 18:46:43
【问题描述】:
我在表单中嵌入了 UISearchBar,所以我想要做的是一旦有人点击 SearchBar,我希望 TableView 作为 subView 弹出。我的工作正常,但是我希望 SubView 出现在 SearchBar 下,以便用户可以继续搜索,我的 SubView 接管整个页面。以下是我试图让该功能发挥作用的方法:Trulia App。 如果您单击 SearchBar,现在请注意具有相应 View 的 searchBar 一个 subView 出现在 SearchBar 的正下方。如前所述,一切正常,除了 subView 接管整个页面并且没有出现在 SearchBar 下方。这是我的代码,第三张图片是我的故事板,这是我的代码
class RegistrationViewController: UIViewController,UISearchBarDelegate {
@IBOutlet weak var Location: UISearchBar!
func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
searchBar.setShowsCancelButton(false, animated: true)
let Popup = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "zip_searches") as! ExampleTableViewController
self.addChildViewController(Popup)
Popup.view.frame = self.view.frame
self.view.addSubview(Popup.view)
Popup.didMove(toParentViewController: self)
return true
}
}
[
【问题讨论】:
标签: ios swift uitableview uisearchbar addsubview