0
我想知道我可以拖放UISearchController
,并将其添加在UINavigationBar
的顶部,而不是编程方式这样做的:如何将UISearchController添加到Storyboard中iOS应用的导航栏中?
var searchController: UISearchController!
var searchResultsTableViewController: UITableViewController!
searchResultsTableViewController = UITableViewController()
searchController = UISearchController(searchResultsController: searchResultsTableViewController)
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.delegate = self
self.navigationItem.titleView = searchController.searchBar
从对象库中拖动并放置在导航栏上不会将它添加到栏中,而是将它放到视图的中心。如何将UISearchController
添加到我的应用的导航栏中?
添加UISearchBar而不是SearchBarController – engmahsa
谢谢@engmahsa,我似乎无法将“UISearchBar”和“UISearchBarController”添加到导航栏。 – Cesare
将导航控制器中的视图控制器嵌入到导航栏中,或者如果您从另一个视图导航栏中导航,则会自动创建导航栏。你的情况究竟是什么? – engmahsa