【发布时间】:2016-07-21 21:30:15
【问题描述】:
我有一个文本字段,它在其 inputview 上显示一个 tableview 并在选择时返回值我向 tableview 添加了一个搜索栏,但问题是,当我点击搜索栏时,tableview 会自动关闭和重新打开,这意味着我什至无法单击搜索栏。有什么建议吗?
这里是代码。
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
}
【问题讨论】:
标签: ios swift uitableview uisearchbar