我正在尝试将搜索栏添加到导航栏中。我做了一些研究,目前为止我已经完成了以下步骤:
但问题是使用这段代码后导航栏中没有任何显示。
searchBar = UISearchBar(frame: CGRectMake(0, 0, 320, 44))
searchBar?.delegate = self
searchBar?.showsCancelButton = true
searchController = UISearchDisplayController()
searchController?.delegate = self
searchController?.searchResultsDelegate = self
searchController?.displaysSearchBarInNavigationBar = true