2
我有文本字段顯示在其inputview上的tableview和返回值select我向tableview添加了一個搜索欄,但問題是,當我點擊searchbar tableview自動關閉和重新打開這意味着我甚至不能點擊搜索欄。有什麼建議?UITableView與搜索欄作爲inputView
這是代碼。
class myClass: UIViewController, UITableViewDataSource, UITableViewDelegate, UINavigationBarDelegate, UISearchBarDelegate {
//the all are in viewdidload
var tableView: UITableView = UITableView()
tableView = UITableView(frame: UIScreen.mainScreen().bounds, style: UITableViewStyle.Plain)
tableView.delegate = self
tableView.dataSource = self
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
let navigationBar = UINavigationBar(frame: CGRectMake(0, 0, self.view.frame.size.width, 44))
let navigationItem = UINavigationItem()
var searchBar:UISearchBar = UISearchBar()
searchBar.searchBarStyle = UISearchBarStyle.Prominent
searchBar.placeholder = " Search..."
searchBar.sizeToFit()
searchBar.translucent = false
searchBar.backgroundImage = UIImage()
searchBar.delegate = self
navigationBar.items = [navigationItem]
tableView.tableHeaderView = navigationBar
toTextField.inputView = self.tableView
}