2017-05-26 83 views
0

我已經在我的UITableViewController的頂部放置了一個searchBar,我不知道如何使它可見。我不想使用searchController.searchBar(它將搜索欄放置在tableView的標題中),因爲我對使用UISearchBarDelegate感興趣。我通過故事板完成了上述內容。如何在UITableView控制器的標題中放置一個搜索欄?當放置在UITableViewController的頂部時看不到搜索欄

回答

2

只需拖動ñ在表視圖控制器的頂部下降搜索欄(只以上prototypecell) enter image description here

enter image description here

+0

感謝花花公子程序添加搜索欄。不知道我是如何錯過的。一直在嘗試! – tim

0

在迅速3+ ​​

private var searchBar: UISearchBar! 

let searchBarView = UIView(frame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(UIScreen.main.bounds.size.width), height: CGFloat(45))) 
searchBar = UISearchBar() 
searchBar.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width , height: 44) 
searchBar.searchBarStyle = UISearchBarStyle.prominent 
searchBar.placeholder = " Search..." 
searchBar.sizeToFit() 
searchBar.isTranslucent = false 
searchBar.delegate = self 
searchBarView .addSubview(searchBar) 
tableView.tableHeaderView=searchBarView; 
相關問題